Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSArray *)phoneNumbers {
- // The difference is I remove all of the objects
- if (_phoneNumbers) {
- [_phoneNumbers removeAllObjects];
- }
- if (!_phoneNumbers) {
- //Create _phoneNumbers array
- _phoneNumbers = [[NSMutableArray alloc]init];
- }
- ABMultiValueRef *phoneNumberRef = ABRecordCopyValue(_contactRef, kABPersonPhoneProperty);
- NSString *phoneNumber = [[NSString alloc] init];
- // Make sure multi value ref exists
- if (phoneNumberRef) {
- CFIndex numberOfPhoneNumbers = ABMultiValueGetCount(phoneNumberRef);
- for (CFIndex i = 0; i < numberOfPhoneNumbers; i++) {
- phoneNumber = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(phoneNumberRef, i);
- CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumberRef, i);
- if (label) {
- [_phoneNumbers addObject:phoneNumber];
- NSLog(@"phoneNumbers count in method: %d", _phoneNumbers.count);
- }
- CFRelease(label);
- }
- CFRelease(phoneNumberRef);
- }
- return _phoneNumbers;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement