Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Addressbook/Add Vcard to Addressbook


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/Add Vcard to Addressbook

This example is the version from Tue, 30th Jul 2012.

Project "Add Vcard to Addressbook.xojo_binary_project"
FileTypes
Filetype special/any
End FileTypes
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) do if obj.folderItemavailable then run obj.folderItem end if loop until not obj.nextItem End EventHandler
EventHandler Sub Open() a=new abAddressbookMBS me.acceptfileDrop "special/any" End EventHandler
Sub run(f as folderItem) dim p as ABPersonMBS dim b as binaryStream dim l,v as string dim n as string dim d as CFBinaryDataMBS dim s as string b=f.openAsBinaryFile(false) if b<>nil then s=b.read(b.length) p=new ABPersonMBS(s) // this constructor creates a abpersonmbs object with the vcard. if p.Handle<>0 then // did it work? // get name v=p.valueForProperty(a.kABFirstNameProperty) l=p.valueForProperty(a.kABLastNameProperty) n=v+" "+l if a.addRecord(p) then msgBox "VCard added for "+n+"." if a.Save then msgBox "Addressbook saved." end if else MsgBox "Failed to add vcard to addressbook." end if else msgbox "This is not a vCard!" END IF b.close end if End Sub
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

See also:

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


The biggest plugin in space...