i trying email value of address book contact.
i need capture email user click , can figure out how syntax right.
i used example picked first email available, trying switch email user selects. started writing //nsstring* email = abrecordcopyvalue(property, );
or how index value of user selected. if had index value of email selected, reuse code had commented out.
- (bool)peoplepickernavigationcontroller: (abpeoplepickernavigationcontroller *)peoplepicker shouldcontinueafterselectingperson:(abrecordref)person property:(abpropertyid)property identifier:(abmultivalueidentifier)identifier { nsstring* name = (__bridge_transfer nsstring*)abrecordcopyvalue(person, kabpersonfirstnameproperty); self.username.text = name; self.mymessage.recpipientname = name; //nsstring* email = abrecordcopyvalue(property) abmultivalueref emails = abrecordcopyvalue(person, kabpersonemailproperty); // if (abmultivaluegetcount(emails) > 0) { // email = (__bridge_transfer nsstring*) // abmultivaluecopyvalueatindex(emails, 0); // } else { // email = @"[none]"; // } self.useremail.text = email; self.mymessage.recipientemail = email; cfrelease(emails); return no; }
this example code comes directly book (http://www.apeth.com/iosbook/ch31.html#_abpeoplepickernavigationcontroller):
- (bool)peoplepickernavigationcontroller: (abpeoplepickernavigationcontroller *)peoplepicker shouldcontinueafterselectingperson:(abrecordref)person property:(abpropertyid)property identifier:(abmultivalueidentifier)identifier { abmultivalueref emails = abrecordcopyvalue(person, property); cfindex ix = abmultivaluegetindexforidentifier(emails, identifier); cfstringref email = abmultivaluecopyvalueatindex(emails, ix); nslog(@"%@", email); // email here if (email) cfrelease(email); if (emails) cfrelease(emails); [self dismissviewcontrolleranimated:yes completion:nil]; return no; }
Comments
Post a Comment