Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AddressBook & ABPerson valueForKey troubles

AddressBook & ABPerson valueForKey troubles
Thread Tools
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Nov 13, 2002, 03:34 PM
 
Hi,

I have a method which takes an ABPerson as an argument, in the method I extract some values from the ABPerson object and display them in text fields. For some reason, the only value that gets displayed is the "kABOrganizationProperty", none of the others show up. Additionally, I get a runtime error in this method that looks like this: --[ABMultiValue length]: selector not recognized. Below is my method where I am having trouble:

Any help would greatly appreciated.

//BEGIN CODE//

-(void)populateFields:(ABPerson *)person {

ABMultiValue *addrs = [person valueForProperty:kABAddressProperty];
NSString *primaryID = [addrs primaryIdentifier];
int idx = [addrs indexForIdentifier:primaryID];
NSDictionary *primaryAddr = [addrs valueAtIndex:idx];

//set city
if ([primaryAddr objectForKey:kABAddressCityKey]!=nil)
[clientCityField setStringValue:[primaryAddr objectForKey:kABAddressCityKey]];
//set street
if ([primaryAddr objectForKey:kABAddressStreetKey]!=nil)
[clientStreetField setStringValue: [primaryAddr objectForKey:kABAddressStreetKey]];
//set State
if ([primaryAddr objectForKey:kABAddressStateKey]!=nil)
[clientStateField setStringValue: [primaryAddr objectForKey:kABAddressStateKey]];
//set Zip code
if ([primaryAddr objectForKey:kABAddressZIPKey]!=nil)
[clientZipCodeField setStringValue: [primaryAddr objectForKey:kABAddressZIPKey]];

//set phone
if ([person valueForProperty:kABPhoneProperty]!=nil)
[clientPhoneField setStringValue: [person valueForProperty:kABPhoneProperty]];
//set email
if ([person valueForProperty:kABEmailProperty]!=nil)
[clientEmailField setStringValue: [person valueForProperty:kABEmailProperty]];
//set first name
if ([person valueForProperty:kABFirstNameProperty]!=nil)
[clientFirstNameField setStringValue: [person valueForProperty:kABFirstNameProperty]];
//set last name
if ([person valueForProperty:kABAddressProperty]!=nil)
[clientLastNameField setStringValue: [person valueForProperty:kABAddressProperty]];//set company name
if([person valueForProperty:kABOrganizationProperty]!=nil)
[clientCompanyField setStringValue:[person valueForProperty:
kABOrganizationProperty]];

}
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Nov 14, 2002, 08:10 PM
 
I figured it out. It was because I was trying to get an object from an ABPerson that could have multiple values, like phone, email, etc.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2