From: Patrick H. <ph...@gm...> - 2007-12-23 22:04:31
|
This is probably more of a cocoa question than a rubycocoa question, so feel free to ignore me :-) I am trying to work with address book, and at least at the moment I am stumped by labels in AbMultiValueCoreDataWrapper. I expect to see "Home", but I get "_$<Home>!$_". Thanks for any help, pointers to docs, etc. pth require 'osx/cocoa' include OSX OSX.require_framework "AddressBook" me = ABAddressBook.sharedAddressBook.me # => #<OSX::ABPerson:0xbf3d8 class='ABPerson' id=0x514af0> addr_info = me.valueForProperty("Address") # => #<OSX::ABMultiValueCoreDataWrapper:0xbf04a class='ABMultiValueCoreDataWrapper' id=0x51f0e0> addr_info.labelAtIndex(0).to_s # => "_$!<Home>!$_" addr_info.identifierAtIndex(0).to_s # => "E2E83CDE-3FE3-4F89-9EBD-1030C483A6D8" |
From: Satoshi N. <sna...@in...> - 2007-12-24 06:58:47
|
Hi, The value comes from a constant, kABHomeLabel. http://developer.apple.com/documentation/UserExperience/Reference/AddressBook/Classes/ABPerson_Class/Reference/Reference.html Proof: require 'osx/cocoa' include OSX OSX.require_framework "AddressBook" puts KABWorkLabel puts KABHomeLabel puts KABOtherLabel Result: _$!<Work>!$_ _$!<Home>!$_ _$!<Other>!$_ -- Satoshi Nakagawa On 2007/12/24, at 7:04, Patrick Hurley wrote: > This is probably more of a cocoa question than a rubycocoa question, > so feel free to ignore me :-) I am trying to work with address book, > and at least at the moment I am stumped by labels in > AbMultiValueCoreDataWrapper. I expect to see "Home", but I get > "_$<Home>!$_". > > Thanks for any help, pointers to docs, etc. > pth > > > require 'osx/cocoa' > include OSX > OSX.require_framework "AddressBook" > > me = ABAddressBook.sharedAddressBook.me # => > #<OSX::ABPerson:0xbf3d8 class='ABPerson' id=0x514af0> > addr_info = me.valueForProperty("Address") # => > #<OSX::ABMultiValueCoreDataWrapper:0xbf04a > class='ABMultiValueCoreDataWrapper' id=0x51f0e0> > addr_info.labelAtIndex(0).to_s # => "_$!<Home>!$_" > addr_info.identifierAtIndex(0).to_s # => > "E2E83CDE-3FE3-4F89-9EBD-1030C483A6D8" > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |
From: Patrick H. <ph...@gm...> - 2007-12-31 14:50:54
|
Thanks for the assistance, I have a followup question, which (to me at least) appears to be a RubyCocoa question, but is probably my lack of understanding of Cocoa. I am now trying to update addresses in the Address Book using RubyCocoa. I have the following code, which based on my reading of the documentation, I though would work, but alas no luck. require 'osx/cocoa' include OSX OSX.require_framework "AddressBook" me = ABAddressBook.sharedAddressBook.me # => #<OSX::ABPerson:0xbf9a0 class='ABPerson' id=0x536ef0> addrs = me.valueForProperty("Address") # => #<OSX::ABMultiValueCoreDataWrapper:0xbf5d6 class='ABMultiValueCoreDataWrapper' id=0x53b330> addr = addrs.valueAtIndex(0) # => #<OSX::NSCFDictionary:0xbf22a class='NSCFDictionary' id=0x53fe30> addr["Street"] = "1234 Anystreet" # => "1234 Anystreet" addr["Street"].to_s # => "1234 Anystreet" addrs.replaceValueAtIndex_withValue(0, addr) # => OSX::OCMessageSendException: Can't get Objective-C method signature for selector 'replaceValueAtIndex:withValue:' of receiver #<OSX::ABMultiValueCoreDataWrapper:0x1f2f2 class='ABMultiValueCoreDataWrapper' id=0x51e640> # ab.save Any help would be very appreciated, Happy New Year pth On Dec 24, 2007 1:57 AM, Satoshi Nakagawa <sna...@in...> wrote: > Hi, > > The value comes from a constant, kABHomeLabel. > > http://developer.apple.com/documentation/UserExperience/Reference/AddressBook/Classes/ABPerson_Class/Reference/Reference.html > > Proof: > > require 'osx/cocoa' > include OSX > OSX.require_framework "AddressBook" > puts KABWorkLabel > puts KABHomeLabel > puts KABOtherLabel > > Result: > > _$!<Work>!$_ > _$!<Home>!$_ > _$!<Other>!$_ > > -- > Satoshi Nakagawa > > > On 2007/12/24, at 7:04, Patrick Hurley wrote: > > > This is probably more of a cocoa question than a rubycocoa question, > > so feel free to ignore me :-) I am trying to work with address book, > > and at least at the moment I am stumped by labels in > > AbMultiValueCoreDataWrapper. I expect to see "Home", but I get > > "_$<Home>!$_". > > > > Thanks for any help, pointers to docs, etc. > > pth > > > > > > require 'osx/cocoa' > > include OSX > > OSX.require_framework "AddressBook" > > > > me = ABAddressBook.sharedAddressBook.me # => > > #<OSX::ABPerson:0xbf3d8 class='ABPerson' id=0x514af0> > > addr_info = me.valueForProperty("Address") # => > > #<OSX::ABMultiValueCoreDataWrapper:0xbf04a > > class='ABMultiValueCoreDataWrapper' id=0x51f0e0> > > addr_info.labelAtIndex(0).to_s # => "_$!<Home>!$_" > > addr_info.identifierAtIndex(0).to_s # => > > "E2E83CDE-3FE3-4F89-9EBD-1030C483A6D8" > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2005. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > Rubycocoa-talk mailing list > > Rub...@li... > > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > |
From: Alpha C. <alp...@gm...> - 2007-12-31 16:54:27
|
On Dec 31, 2007 6:50 AM, Patrick Hurley <ph...@gm...> wrote: > addrs = me.valueForProperty("Address") # => > #<OSX::ABMultiValueCoreDataWrapper:0xbf5d6 > class='ABMultiValueCoreDataWrapper' id=0x53b330> > addr = addrs.valueAtIndex(0) # => > #<OSX::NSCFDictionary:0xbf22a class='NSCFDictionary' id=0x53fe30> > addr["Street"] = "1234 Anystreet" # => "1234 Anystreet" > addr["Street"].to_s # => "1234 Anystreet" > addrs.replaceValueAtIndex_withValue(0, addr) # => > OSX::OCMessageSendException: Can't get Objective-C method signature > for selector 'replaceValueAtIndex:withValue:' of receiver > #<OSX::ABMultiValueCoreDataWrapper:0x1f2f2 > class='ABMultiValueCoreDataWrapper' id=0x51e640> > # ab.save Try using addrs = addrs.mutableCopy to get an ABMutableMultiValue that you can modify. You'll probably need to use me.setValue_forProperty to write the changes back to the person record. Also, you should probably be using the KABAddressProperty constant to access the addresses in the me.valueForProperty method. Regards, Alpha |
From: Patrick H. <ph...@gm...> - 2007-12-31 17:39:53
|
On Dec 31, 2007 11:54 AM, Alpha Chen <alp...@gm...> wrote: > Try using addrs = addrs.mutableCopy to get an ABMutableMultiValue that > Alpha > Thanks that was perfect pth |
From: Patrick H. <ph...@gm...> - 2007-12-31 23:26:57
|
Just to show I am not a complete help vampire, here (http://pastie.textmate.org/private/fkshzuztdn1aai1x8j7sw) is a semi-handy Ruby script to process your address book, finding any entries without phone numbers, but with an address. It then goes out to anywho.com and looks up the phone number and adds it to your address book. If you are curious I managed to import my xmas card list into address book and used it for my mailing this year, but did not have phone numbers, now I do. Thanks everyone for your help, pth |