Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Addressbook/Extract Vcard
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Addressbook/Extract Vcard
This example is the version from Tue, 30th Jul 2012.
Project "Extract Vcard.rbp"
FileTypes
Filetype special/any
End FileTypes
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Function DragRow(drag As DragItem, row As Integer) As Boolean dim p as ABPersonMBS dim s as string dim id as string dim r as ABRecordMBS // get id id=me.cell(row,0) if id<>"" then // find person for id r=a.recordForUniqueId(id) if r isa ABPersonMBS then p=ABPersonMBS(r) // cast this object to ABPerson // get vcard s=p.vCardRepresentation if s<>"" then // do the drag drag.text=s System.DebugLog "Drag" return true else System.DebugLog "vcard not found" end if else System.DebugLog "person not found" end if else System.DebugLog "id not found" end if End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() a=new ABAddressbookMBS dim pa() as ABPersonMBS = a.people for each p as ABPersonMBS in pa dim uid as string = p.valueForProperty(a.kABUIDProperty) dim firstname as string = p.valueForProperty(a.kABFirstNameProperty) dim lastname as string = p.valueForProperty(a.kABLastNameProperty) list.addrow uid dim l as integer = list.lastIndex list.cell(l,1) = firstname list.cell(l,2) = lastname // gettting the primary email address is a little bit compilcate: dim m as ABMultiValueMBS = p.valueForProperty(a.kABEmailProperty) if m<>Nil then dim id as String = m.PrimaryIdentifier if id<>"" then dim index as integer = m.IndexForIdentifier(id) list.cell(l,3)=m.valueAtIndex(index) end if end if next End EventHandler
Property Protected a As abaddressbookMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if End EventHandler
End Class
End Project

Feedback, Comments & Corrections

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




Links
MBS Xojo PDF Plugins