iphone - app crashes when using kABPersinPhoneProperty -


i trying phone number phone book of iphone. app crashes try fetch number using kabpersonphoneproperty. code snippet here

abaddressbookref addressbook = abaddressbookcreate();  nsmutablearray *allpeople = (nsmutablearray*)abaddressbookcopyarrayofallpeople(addressbook);  int npeople = abaddressbookgetpersoncount(addressbook);  cfrelease(addressbook);  for(int i=0; < npeople; i++ ){      abrecordref person = [allpeople objectatindex:i];     nsstring *name = @"";     cftyperef fname = abrecordcopyvalue(person, kabpersonfirstnameproperty);     cftyperef lname = abrecordcopyvalue(person, kabpersonlastnameproperty);     abmultivalueref multi = abrecordcopyvalue(person , kabpersonphoneproperty);     nsstring *number = (nsstring *)abmultivaluecopyvalueatindex(multi, 0);      if ([number length] > 0) {         if(fname != null)         {             if (lname != null) {                 name = [[nsstring stringwithformat:@"%@", fname] stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset]];             }             else {                 name = [[nsstring stringwithformat:@"%@", fname] stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset]];             }             nslog(@"number==>%@ ",number);         }     }     if (fname != null) {         cfrelease(fname);     }     if (lname != null) {         cfrelease(lname);     }     if (multi != null) {         cfrelease(multi);     } }  [allpeople release]; 

i unable figure out error in this. releasing not running smoothly.

i getting potential memory leak when running build , analyze code part

abmultivalueref multi = abrecordcopyvalue(person , kabpersonphoneproperty);     nslog(@"number===>%d" , abmultivaluegetcount(multi)); 

please me out come.

any kind of highly appreciated.

thanks in advance

thanks response. have figured out solution fot problem here. did not release number variable thinking reference passed reference copied returned location, hence need release number after usage.

thanks again responses!!


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -