I am getting an error:
Implicit conversion of C pointer type 'ABRecordRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast
from this code, trying to add an ABRecordRef
to an NSMutableArray
ABRecordRef person = (__bridge ABRecordRef)[contactArr objectAtIndex:i];
[addressBookArray addObject:person];
addressBookArray
is defined as
NSMutableArray *addressBookArray;
As the error message says, you need to re-cast the object in order to put it back into an NSMutableArray
:
ABRecordRef person = (__bridge ABRecordRef)[contactArr objectAtIndex:i];
[addressBookArray addObject:(__bridge ABRecord *)person];
ABRecord
is the ObjC class that corresponds to ABRecordRef
; they're toll-free bridged, so they are interchangeable for this purpose.
Note: ABRecord
is only available on OS X. If you're on iOS and somehow managed to get those ABRecordRef
s into an NSArray
in the first place, you'll have to use id
for the re-cast
[addressBookArray addObject:(__bridge id)person];