I have figured out how to edit a contact in the address book (contacts) on mac. For example i can change the first name etc.
However, i can’t seem to change the image? Below is my code. Only testing, so i does nothing useful and is slapped together for testing.
Anyone see what i am doing wrong?
dim f as FolderItem
dim p as Picture
f = GetopenFolderItem(“png”)
p = f.OpenAsPicture
Dim i as Integer
Dim book as AddressBook
Dim Contacts() as AddressBookContact
For i =0 to Ubound(Contacts)
if Contacts(i).companyname = "Test Company" then
contacts(i).FirstName = "Harry"
contacts(i).Image = p
if book.save = true then
It’s funny the LR does not show an image property for AddressBookContact, and hovering about the property in Code Editor shows no class nor data type. The last time I was playing around with the AddressBook class I found there was no image property and I used a declared implementation of ABAddressBook and its partner classes to change the image. When was image implemented? Is this maybe a case for a bug report?
See my thread on a similar issue:
It also seems that you cannot create a Homepage entry in the address book either?
I posted it 3 days ago, but nobody has either confirmed or denied this
Im not sure when it was implemented, I was looking at this around 8 months ago and didn’t see it then, but thought I must have over looked it back then. Maybe it has only just been introduced since then?
No error is thrown, just doesn’t work. Cant be sure if my code is wrong as there is no documentation!
I would love to know more about your way of making it work. I don’t have the MBS plugin, but might be persuaded to get it if I know it will work.
@Andrew, @Richard: Currently there’s much focus on the progress of the next versions, see Norman’s info line: “Only watching Alphas & Betas”. Could you please file a bug report? All your information sounds like there’s something not quite right and at least the LR should be updated to contain the image property.
Yes, I have already seen that post, but it still doesn’t solve the issue.
Maybe simply use classes for address book from MBS Cocoa Plugin as an alternative?
Do you have a link for documentation of the plugin? I looked at the pdf but it makes no mention of the address book. If I can see that it will work via documentation, then it might just be an option.
any chance of you creating an example project, which creates a new address book entry and inserts data for each category?
just a further note.
If i write:
then it clears the picture for the contract.
So the property is working, just not sure what needs to be the value.
I also tried to convert the picture item into a memory block and have that as the value with :
dim mb as MemoryBlock
mb = P.GetData(Picture.FormatJPEG, Picture.QualityHigh)
But i just get the old:
“There is more than one item with this name and it’s not clear to which this refers.” error message
I know for sure that an image can be added creating a vCard (the memoryblock must be encoded as Base64). Then double-clicking the vCard, it gets added to AB with the expected image.
But I dont know if this procedure works with Xojo’s AB function.
On the other end, I just discovered today that importing contacts from AB doesnt import images anymore.
To get images it seems that each contact has to be exported by AB as vCard; then an app can read the vCard plus image.
But accessing AB from Xojo-AB and using contact(n).vCard doesnt work: contact(n).vCard does not contain the encoded image.
In one word: to get an image, the vCard created by AB has to opened via getFolderitem or drag-n-drop.
Sometime I think Apple wants to make our lives miserable.