Platforms to show: All Mac Windows Linux Cross-Platform

Back to ABAddressBookMBS class.

ABAddressBookMBS.accountWithIdentifier(Identifier as string) as ABAccountMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Finds account with matching identifier.

ABAddressBookMBS.addRecord(record as ABRecordMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds a record (ABPersonMBS or ABGroup) to the AddressBook Database
Example
dim a as new ABAddressBookMBS
dim p as new ABPersonMBS

if not p.setValue("Miller",a.kABLastNameProperty) then
MsgBox "Failed to set field "+a.LocalizedPropertyOrLabel(a.kABLastNameProperty)
end if

if not p.setValue("Ben",a.kABFirstNameProperty) then
MsgBox "Failed to set field "+a.LocalizedPropertyOrLabel(a.kABFirstNameProperty)
end if

if a.addRecord(p) then
MsgBox "Record added"
else
MsgBox "Failed to add record"
end if

if a.save then
MsgBox "Changes saved"
else
MsgBox "Failed to save changes"
end if

Returns true if the addition was successful

See also:

ABAddressBookMBS.addRecord(record as ABRecordMBS, Account as ABAccountMBS, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds a record (ABPersonMBS or ABGroup) to the AddressBook Database with given account.

Returns true if the addition was successful.
On Mac OS X 10.7 the error parameter is set to describe the error.

See also:

ABAddressBookMBS.addRecord(record as ABRecordMBS, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds a record (ABPersonMBS or ABGroup) to the AddressBook Database.

Returns true if the addition was successful.
On Mac OS X 10.7 the error parameter is set to describe the error.

See also:

ABAddressBookMBS.allAccounts as ABAccountMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries list of all accounts.
Example
dim a as new ABAddressBookMBS
dim accounts() as ABAccountMBS = a.allAccounts
Break // look in debugger

Some examples using this method:

ABAddressBookMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 13.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The constructor.

ABAddressBookMBS.enabledAccounts as ABAccountMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries list of enabled accounts.
Example
dim a as new ABAddressBookMBS
dim accounts() as ABAccountMBS = a.enabledAccounts
Break // look in debugger

ABAddressBookMBS.EnableEvent

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Activates the events in this class.

You only need to call this if you use AddHandler command in Xojo to add event handlers. The plugin automatically does that in the constructor, but that is too early for AddHandler. And plugin on enables events if you use them.

ABAddressBookMBS.formattedAddressFromDictionary(address as Dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an attributed string containing the formatted address.

The string's attributes match address dictionary keys (kABAddressStreetKey for example).
Each attribute value contains the localized description of the key. (For example, the value of a Canadian kABAddressZIPKey field would be Postal Code)

Some examples using this method:

ABAddressBookMBS.groupForName(name as string) as ABGroupMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Searches the group with the given name.
Example
dim a as new ABAddressBookMBS
dim name as string = "Some Group"
dim g as ABGroupMBS = a.groupForName(name)
MsgBox g.DisplayName+": "+str(g.members.Ubound+1)

ABAddressBookMBS.groupForUniqueId(uniqueid as string) as ABGroupMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a ABGroupMBS matching a given unique ID.
Example
dim a as new ABAddressBookMBS

// you have some uid
dim groups() as ABGroupMBS = a.groups
dim uid as string = groups(0).valueForProperty(a.kABUIDProperty)

// later you want to find the group
dim g as ABGroupMBS = a.groupForUniqueId(uid)

// shows the name
MsgBox g.valueForProperty(a.kABGroupNameProperty)

Returns nil if the record could not be found or matches to a person.
Available in Mac OS X 10.3 or newer.
see also recordForUniqueId.

See also:

ABAddressBookMBS.groupForUniqueId(uniqueid as string, account as ABAccountMBS) as ABGroupMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Finds a group for given unique ID for given account.

See also:

ABAddressBookMBS.groups as ABGroupMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an array of all the groups in the AddressBook database
Example
// list all email addresses in one group

Dim book as ABAddressBookMBS
dim groups() as ABGroupMBS
dim person as ABPersonMBS
dim data as ABMultiValueMBS
dim s as string

book=new ABAddressBookMBS

groups=book.groups

for each group as ABGroupMBS in groups
If group.valueForProperty(book.kABGroupNameProperty)= "test" then // or any valid group
dim members() as ABPersonMBS = group.members

for each member as ABPersonMBS in members

data=person.valueForProperty(book.kABEmailProperty)

if data<>nil then
for k as Integer=data.count-1 downto 0
s=s+data.valueAtIndex(k)+EndOfLine
next
end if
next
end if
Next
msgBox s

Returns an empty array in case the DB doesn't contain any groups.
Returns nil on any error.

Some examples using this method:

ABAddressBookMBS.groupsForAccount(account as ABAccountMBS) as ABGroupMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an array of all the groups for this account.
Example
dim a as new ABAddressBookMBS
dim c as ABAccountMBS = a.defaultAccount
dim groups() as ABGroupMBS = a.groupsForAccount(c)

Break // look in debugger

Returns an empty array in case the DB doesn't contain any body.

Some examples using this method:

ABAddressBookMBS.LocalizedPropertyOrLabel(propertyOrLabel as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the localized version of built in properties, labels or keys

Returns propertyOrLabel if not found (e.g. if not built in).

Some examples using this method:

ABAddressBookMBS.NewPersonWithVCardRepresentation(data as memoryblock) as ABPersonMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Create a person from a vCard.

Returns nil on failure.
Convenience function which cen be used instead of the ABPersonMBS constructor.

ABAddressBookMBS.people as ABPersonMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an array of all the people in the AddressBook database
Example
dim a as new ABAddressBookMBS

// get all people
dim p(-1) as ABPersonMBS = a.people

// walk over people list
for each m as ABPersonMBS in p
try
// ask for image

dim j as NSImageMBS = m.image

// do something with image
if j<>nil then
Backdrop=j.CopyPictureWithMask
end if

catch x as NSExceptionMBS
// raises exception if there is no image
end try
next

Returns an empty array in case the DB doesn't contain any body.
Returns nil on any error.

Some examples using this method:

ABAddressBookMBS.peopleForAccount(account as ABAccountMBS) as ABPersonMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an array of all the people for this account.
Example
dim a as new ABAddressBookMBS
dim c as ABAccountMBS = a.defaultAccount
dim people() as ABPersonMBS = a.peopleForAccount(c)

Break // look in debugger

Returns an empty array in case the DB doesn't contain any body.

ABAddressBookMBS.peopleForEmail(email as string) as ABPersonMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Searches a contact for the given email.
Example
dim a as new ABAddressBookMBS
dim persons() as ABPersonMBS = a.peopleForEmail("support@monkeybreadsoftware.de")

if UBound(persons) >= 0 then
MsgBox persons(0).DisplayName
else
MsgBox "nothing found."
end if

ABAddressBookMBS.persistentAccounts as ABAccountMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries list of all persistent accounts.
Example
dim a as new ABAddressBookMBS
dim accounts() as ABAccountMBS = a.persistentAccounts
Break // look in debugger

ABAddressBookMBS.personForUniqueId(uniqueid as string) as ABPersonMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a ABPersonMBS matching a given unique ID.
Example
dim a as new ABAddressBookMBS

// you have some uid
dim uid as string = a.owner.valueForProperty(a.kABUIDProperty)

// later you want to find the person
dim p as ABPersonMBS = a.personForUniqueId(uid)

// shows the name
MsgBox p.valueForProperty(a.kABFirstNameProperty)

Returns nil if the record could not be found or matches to a group.
Available in Mac OS X 10.3 or newer.
see also recordForUniqueId.

See also:

ABAddressBookMBS.personForUniqueId(uniqueid as string, account as ABAccountMBS) as ABPersonMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Finds a person for given unique ID for given account.

See also:

ABAddressBookMBS.recordClassFromUniqueId(uniqueid as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Given a record uniqueId returns the record class name.

Return "ABPersonMBS" or "ABGroup" or "" for a given uniqueid.

ABAddressBookMBS.recordForUniqueId(uniqueid as string) as ABRecordMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a record (ABPersonMBS or ABGroup) matching a given unique ID.
Example
dim a as new ABAddressBookMBS

// you have some uid
dim uid as string = a.owner.valueForProperty(a.kABUIDProperty)

// later you want to find the person
dim r as ABRecordMBS = a.recordForUniqueId(uid)
if r isa ABPersonMBS then
dim p as ABPersonMBS = ABPersonMBS(r)

// shows the name
MsgBox p.valueForProperty(a.kABFirstNameProperty)
end if

Returns nil if the record could not be found.
Available in Mac OS X 10.3 or newer.

See also:

Some examples using this method:

ABAddressBookMBS.recordForUniqueId(uniqueid as string, account as ABAccountMBS) as ABRecordMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Finds a record for given unique ID for given account.

See also:

ABAddressBookMBS.recordsMatchingSearchElement(search as ABSearchElementMBS) as ABRecordMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an array of records matching the given search element
Example
dim ab as new ABAddressBookMBS

// search for people with birthday, by searching for dates starting 1901.
dim searchDate as new date( 1901, 1, 1 )
dim search as ABSearchElementMBS = ab.SearchElementForPersonProperty( ab.kABBirthdayProperty, "", "", searchDate, ab.kABGreaterThan )

// do the search
dim people() as ABRecordMBS = ab.RecordsMatchingSearchElement( search )


for each person as ABRecordMBS in people
dim p as ABPersonMBS = ABPersonMBS( person )
// now work on them
next

Returns an empty array if no matches or an error.

Some examples using this method:

ABAddressBookMBS.removeRecord(record as ABRecordMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes a record (ABPersonMBS or ABGroup) from the AddressBook Database

Returns true if the removal was successful.

See also:

ABAddressBookMBS.removeRecord(record as ABRecordMBS, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes a record (ABPersonMBS or ABGroup) from the AddressBook Database.

Returns true if the removal was successful.
On Mac OS X 10.7 the error parameter is set to describe the error.

See also:

ABAddressBookMBS.save as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Saves changes made since the last save.

Return true if successful (or there was no change).

See also:

ABAddressBookMBS.save(byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Saves changes made since the last save.

Return true if successful (or there was no change).
On Mac OS X 10.5 the error object is returned. On Mac OS X 10.4 this error property is nil and you only can use the result.

See also:

ABAddressBookMBS.setMe(moi as ABPersonMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Addressbook MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Sets "Me" to moi.

Pass nil to clear "Me".

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


The biggest plugin in space...