Tuesday, 15 April 2014

iphone - changing ABRecordRef property -



iphone - changing ABRecordRef property -

i have next cpde:

abrecordref person = abaddressbookgetpersonwithrecordid(addressbook, abrecordgetrecordid(self.recordref_)); cferrorref error = null; if ([self.nametextfield_.text isnotnull]){ nsarray *namestringarray = [self.nametextfield_.text componentsseparatedbycharactersinset:[nscharacterset whitespacecharacterset]]; abrecordsetvalue(person, kabpersonfirstnameproperty, (__bridge cftyperef)([namestringarray objectatindex:0]), null); if ([namestringarray count] > 1){ abrecordsetvalue(person, kabpersonlastnameproperty, (__bridge cftyperef)([namestringarray lastobject]), &error); } }

however, after code gives me error:

error domain=abaddressbookerrordomain code=0 "the operation couldn’t completed. (abaddressbookerrordomain error 0.)"

any thought why is?

the error message seems pretty useless, rest of code looks valid, guess application hasn't been authorized user access address book database. utilize code next check authorization status before attempting access adress book:

if (abaddressbookgetauthorizationstatus() == kabauthorizationstatusauthorized) { // we're go } else { // hasn't been authorized user // can check exact authorization status more info on // exact reason why can't access address book (e.g. denied, restricted, etc.) }

iphone ios objective-c ipad

No comments:

Post a Comment