ios - ABPersonSocialProfile crash app -


i have problem adding new social profiles abrecordref. return crash on abadressbooksave "[__nscfstring count]: unrecognized selector sent instance"

abmultivalueref social = abmultivaluecreatemutable(kabmultidictionarypropertytype); if(contact.socialtwitter != nil)     abmultivalueaddvalueandlabel(social, (__bridge cftyperef)([nsdictionary dictionarywithobjectsandkeys:                                                                (nsstring*)kabpersonsocialprofileservicetwitter, kabpersonsocialprofileservicekey,                                                                (__bridge cfstringref)contact.socialtwitter, kabpersonsocialprofileusernamekey,                                                                nil]), kabpersonsocialprofileservicetwitter, null);   abrecordsetvalue(record, kabpersonsocialprofileproperty, social, &error); cfrelease(social); 

i had same issue while saving new contact. seems can't save attributes this. below code worked me.

abrecordref arecord = abpersoncreate();              cferrorref  anerror = null;              // username             abrecordsetvalue(arecord, kabpersonfirstnameproperty, username, &anerror);              // phone number.             abmutablemultivalueref multi = abmultivaluecreatemutable(kabmultistringpropertytype);             abmultivalueaddvalueandlabel(multi, (cfstringref)usercontact, kabworklabel, null);             abrecordsetvalue(arecord, kabpersonphoneproperty, multi, &anerror);             cfrelease(multi);              // company             abrecordsetvalue(arecord, kabpersondepartmentproperty, usercompany, &anerror);              // email             nslog(useremail);             abmutablemultivalueref multiemail = abmultivaluecreatemutable(kabmultistringpropertytype);             abmultivalueaddvalueandlabel(multiemail, (cfstringref)useremail, kabworklabel, null);             abrecordsetvalue(arecord, kabpersonemailproperty, multiemail, &anerror);             cfrelease(multiemail);              // website             nslog(userwebsite);             abmutablemultivalueref multiweb = abmultivaluecreatemutable(kabmultistringpropertytype);             abmultivalueaddvalueandlabel(multiweb, (cfstringref)userwebsite, kabworklabel, null);             abrecordsetvalue(arecord, kabpersonurlproperty, multiweb, &anerror);             cfrelease(multiemail);              // function             abrecordsetvalue(arecord, kabpersonjobtitleproperty, userrole, &anerror);              if (anerror != null)                 nslog(@\"error while creating..\");              cfstringref personname, personcompind, personemail, personfunction,  personwebsite, personcontact;              personname = abrecordcopyvalue(arecord, kabpersonfirstnameproperty);              personcompind = abrecordcopyvalue(arecord, kabpersondepartmentproperty);              personfunction = abrecordcopyvalue(arecord, kabpersonjobtitleproperty);              personemail = abrecordcopyvalue(arecord, kabpersonemailproperty);             personwebsite = abrecordcopyvalue(arecord, kabpersonurlproperty);             personcontact  = abrecordcopyvalue(arecord, kabpersonphoneproperty);               abaddressbookref addressbook;              cferrorref error = null;              addressbook = abaddressbookcreate();               bool isadded = abaddressbookaddrecord (addressbook, arecord, &error);              if(isadded){                  nslog(@\"added..\");             }             if (error != null) {                 nslog(@\"abaddressbookaddrecord %@\", error);             }              error = null;              bool issaved = abaddressbooksave (addressbook, &error);              if(issaved) {                  nslog(@\"saved..\");                 uialertview *alertonchoose = [[uialertview alloc] initwithtitle:@\"phone added addressbook\" message:nil delegate:self cancelbuttontitle:nil otherbuttontitles:@\"ok\", nil];                 [alertonchoose show];                 [alertonchoose release];             }              if (error != null) {                  nslog(@\"abaddressbooksave %@\", error);                 uialertview *alertonchoose = [[uialertview alloc] initwithtitle:@\"unable save time\" message:nil delegate:self cancelbuttontitle:nil otherbuttontitles:@\"ok\", nil];                 [alertonchoose show];                 [alertonchoose release];             }               cfrelease(arecord);              cfrelease(personname);             cfrelease(personcompind);             cfrelease(personcontact);             cfrelease(personemail);             cfrelease(personfunction);             cfrelease(personwebsite);               cfrelease(addressbook); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -