Platforms to show: All Mac Windows Linux Cross-Platform

ABSearchElementMBS class   Deprecated

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
This item is deprecated and should no longer be used. You can use CNContactFetchRequestMBS class instead.
A class for a search element.
Example
// 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)
end if

if d<>Nil then
// show address with street and city
listbox1.Cell(listbox1.LastIndex,1) = d.Lookup(addr.kABAddressStreetKey,"")+" "+d.Lookup(addr.kABAddressCityKey,"")
end if
end if
end if
next

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.

Constants

Constant Value Description
kABSearchAnd 0 A search conjunction.
kABSearchOr 1 A search conjunction.

This class has no sub classes.

Some methods using this class:

Some examples using this class:

Blog Entries


The items on this page are in the following plugins: MBS MacCocoa Plugin.


ABRecordMBS   -   ACAccountCredentialMBS


The biggest plugin in space...