Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

ABSearchElementMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Addressbook MBS MacCocoa Plugin 7.1 Yes No No Yes, macOS only No
Function: 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
Notes:
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.

Feedback, Comments & Corrections

This class has no sub classes.

Some methods using this class:

Some examples which use this class:


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


ABRecordMBS   -   ACAccountCredentialMBS





Links
MBS Xojo tutorial videos