|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||Addressbook||MBS MacCocoa Plugin||7.1||Yes||No||No||Yes, macOS only||No|
// search and display all entries with a given name in a 2 column listbox with address
// Save reference to caller.
dim addr as new ABAddressBookMBS // Initialise the Address Book plugin
dim searchName as string = "Schmitz" // search on.
// Do the search
dim srch as ABSearchElementMBS = addr.searchElementForPersonProperty(addr.kABLastNameProperty, "", "", searchName, addr.kABContainsSubStringCaseInsensitive)
dim srchRes() as ABRecordMBS = addr.recordsMatchingSearchElement(srch) // Get the results into an array
for each rc as ABRecordMBS in srchRes
if rc isa ABPersonMBS then // Is it a person record?
dim pers as ABPersonMBS = ABPersonMBS(rc) // Get it into a personnel record
// Now get out the names and addresses.
listbox1.AddRow(pers.valueForProperty(addr.kABFirstNameProperty) + " " + pers.valueForProperty(addr.kABLastNameProperty))
listbox1.RowTag(listbox1.LastIndex) = pers.valueForProperty(addr.kABUIDProperty)
// Need to find the home address.
dim mlv as ABMultiValueMBS = pers.valueForProperty(addr.kABAddressProperty)
if mlv <> nil Then
// get home address
dim d as Dictionary = mlv.valueForLabel(addr.kABHomeLabel)
if d = nil then
// get primary
d = mlv.valueForIdentifier(mlv.primaryIdentifier)
if d<>Nil then
// show address with street and city
listbox1.Cell(listbox1.LastIndex,1) = d.Lookup(addr.kABAddressStreetKey,"")+" "+d.Lookup(addr.kABAddressCityKey,"")
Use searchElementForProperty in ABPersonMBS and ABGroupMBS classes to create objects.
All methods in this class will catch exceptions from Cocoa and raise a NSExceptionMBS instead. Using the message, name and reason properties you can see what was the reason for this exception. Please report if you find a method which does not handle exceptions correct.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.
- 3 properties
- 2 methods
- shared method searchElementForConjunction(conjunction as Integer, children() as ABSearchElementMBS) as ABSearchElementMBS
- 2 constants
This class has no sub classes.
Some methods using this class:
- ABAddressBookMBS.recordsMatchingSearchElement(search as ABSearchElementMBS) as ABRecordMBS()
- ABAddressBookMBS.searchElementForConjunction(conjunction as Integer, children() as ABSearchElementMBS) as ABSearchElementMBS
- ABAddressBookMBS.searchElementForGroupProperty(PropertyName as string, Label as string, Key as string, value as Variant, comparison as Integer) as ABSearchElementMBS
- ABAddressBookMBS.searchElementForPersonProperty(PropertyName as string, Label as string, Key as string, value as Variant, comparison as Integer) as ABSearchElementMBS
- ABGroupMBS.searchElementForProperty(PropertyName as string, Label as string, Key as string, value as Variant, comparison as Integer) as ABSearchElementMBS
- ABPersonMBS.searchElementForProperty(PropertyName as string, Label as string, Key as string, value as Variant, comparison as Integer) as ABSearchElementMBS
Some examples which use this class:
- /MacCocoa/Addressbook/Add person
- /MacCocoa/Addressbook/Easy search
- /MacCocoa/Addressbook/Search Person
The items on this page are in the following plugins: MBS MacCocoa Plugin.
MBS Xojo Chart Plugins