objective c - IOS AdressBook Contacts Null Issue on real device -


i getting contacts addressbook , tested on simulator there no first or second name null issue.

but when trying test on real device give me first or second name null issue on many rows. please me source code is

- (void)getcontactswithaddressbook:(abaddressbookref )addressbook {     contactlist = [[nsmutablearray alloc] init];     cfarrayref allpeople = abaddressbookcopyarrayofallpeople(addressbook);     cfindex npeople = abaddressbookgetpersoncount(addressbook);      (int i=0;i < npeople;i++) {         nsmutabledictionary *dofperson=[nsmutabledictionary dictionary];          abrecordref ref = cfarraygetvalueatindex(allpeople,i);          //for username , surname         abmultivalueref phones =(__bridge abmultivalueref)((__bridge nsstring*)abrecordcopyvalue(ref, kabpersonphoneproperty));          cfstringref firstname, lastname;         firstname = abrecordcopyvalue(ref, kabpersonfirstnameproperty);         lastname  = abrecordcopyvalue(ref, kabpersonlastnameproperty);         [dofperson setobject:[nsstring stringwithformat:@"%@ %@", firstname, lastname] forkey:@"name"];          //for email ids         abmutablemultivalueref email  = abrecordcopyvalue(ref, kabpersonemailproperty);         if(abmultivaluegetcount(email) > 0) {             [dofperson setobject:(__bridge nsstring *)abmultivaluecopyvalueatindex(email, 0) forkey:@"email"];          }          //for phone number         nsstring* mobilelabel;          for(cfindex = 0; < abmultivaluegetcount(phones); i++) {             mobilelabel = (__bridge nsstring*)abmultivaluecopylabelatindex(phones, i);             if([mobilelabel isequaltostring:(nsstring *)kabpersonphonemobilelabel])             {                 [dofperson setobject:(__bridge nsstring*)abmultivaluecopyvalueatindex(phones, i) forkey:@"phone"];             }             else if ([mobilelabel isequaltostring:(nsstring*)kabpersonphoneiphonelabel])             {                 [dofperson setobject:(__bridge nsstring*)abmultivaluecopyvalueatindex(phones, i) forkey:@"phone"];                 break ;             }          }         [contactlist addobject:dofperson];      }      nslog(@"contacts = %@",contactlist);   } 

probably don't have first name/last name contacts can this

nsstring *firstname = (__bridge nsstring *)abrecordcopyvalue(person, kabpersonfirstnameproperty)==nil?@"":(__bridge nsstring *)abrecordcopyvalue(person, kabpersonfirstnameproperty);  nsstring *lastname = (__bridge nsstring *)abrecordcopyvalue(person, kabpersonlastnameproperty)==nil?@"":(__bridge nsstring *)abrecordcopyvalue(person, kabpersonlastnameproperty); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -