working with a peoplePicker

So I added a people picker to my app. It shows up and brings in all my contact info but it only shows the names of the people. How do you get the peoplepicker to display more then just the name. Street, city, zip, company etc…
Thanks

Hi,

use the addProperty: method

Where and how do I use this

use the addProperty: method

look into the documentation of ABPeoplePickerView

[i]addProperty:
Adds a property to the group of properties whose values are shown in the record list.

  • (void)addProperty:(NSString *)property[/i]

in ASOC for example to add the address column
assuming picker is a ABPeoplePickerView instance


picker's addProperty_(current application's kABAddresslProperty);

Stefan, I appreciate the help. But I am a beginner at this. I looked at the help and what I don’t understand is where to put that line of code in my script.

I tried in my

on applicationWillFinishLaunching_(aNotification)
thePPV's addProperty_(current application's kABAddresslProperty);

but it does not compile unless I remove the semi colon from the end.

sorry, of course the semicolon must be removed, I used ObjC-code.
And the string constant is misspelled: correct is kABAddressProperty

that did the trick. Thanks so much stevan

Stevan, one last question. Im reading thru and looking at my logs. I figured out how to pull out the company name. But im struggling with the email. Im guessing the difficulty is coming into play because there could be more then 1 email.

All I am looking to do is grab the first email address listed for the contact if there is one. Is this doable?

emails is a multi-value object.
To get the first email address of the selected contact try this


set emailAddresses to picker's selectedValues()
if emailAddresses's |count|() > 0 then
	set foundAddress to emailAddresses's objectAtIndex_(0)
else
 	set foundAddress to missing value
end if

No luck, When I try the code below, my log spits out the following only

set emailAddresses to ppv's selectedValues()
		if emailAddresses's |count|() > 0 then
			set foundAddress to emailAddresses's objectAtIndex_(0)
			log foundAddress
		else
			set foundAddress to missing value
			log "No Email found"
		end if

The Log

{
City = Dallas;
Country = USA;
State = TX;
Street = “10865 Sanden Drive”;
ZIP = 75238;
}

adding the address property was just an example.
If you want to get email information add kABEmailProperty instead.

It’s also possible to get the information from the person record
The handler push() is invoked by a button, picker is the ABPeoplePickerView instance


on push_(sender)
		set selectedRecords to picker's selectedRecords()
		if (not ((selectedRecords is missing value) as boolean) and selectedRecords's |count|() > 0) then
			set selectedPerson to selectedRecords's objectAtIndex_(0)
			set allEmails to selectedPerson's valueForProperty_(current application's kABEmailProperty)
			if (allEmails's |count|() > 0) then
				set foundEmail to allEmails's valueAtIndex_(0)
				display dialog foundEmail as string
			else
				displayAlert_("No emails available")
			end
		else
			displayAlert_("Nothing selected")
		end
end push_	
	
on displayAlert_(msg)
	set alert to current application's NSAlert's alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_("nothing selected", missing value, missing value, missing value, "")
	alert's runModal()
end displayAlert_