// 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 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:
The items on this page are in the following plugins: MBS Real Studio Cocoa Plugin.
Christians Software aus Nickenich