I have an mutableArray and put the number of a contact in it.
I use the following code:
ABMultiValueRef phoneNumbers = (ABMultiValueRef)ABRecordCopyValue(person, kABPersonPhoneProperty);
CFRelease(phoneNumbers);
number = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
[thenumbers addObject:number];
In order to retrieve it, I do this:
Contacts *num = [thenumbers objectAtIndex:indexPath.row];
NSString *numbers = [NSString stringWithFormat:@"%@", [num number]];
cell.detailTextLabel.text = numbers;
I set breakpoints and it stops at the right lines. I also tried
NSLog(@"%@", number);
And it returns the numbers. And yes I have reloadDate in viewWillappear.
You’re releasing
phoneNumbersstraight after copying to it. Try moving it to after you use it.Or, better still, transfer the ownership to the NSString object through ARC
And there is no need to call
CFRelease(phoneNumbers)at all.As for getting the numbers into the cell, you’re getting confused about your types. You’re putting an
NSStringintotheNumberbut your pulling out aContacts. And then sending it some kind ofnumbermessage.You’ve put a string in the array, you can only pull out a string or a subclass.