I copied this method, line by line from the apple dev library and getting casting errors for the two NSString casts. How can those be resolved? (I am using ARC)
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person {
NSString* name = (NSString *)ABRecordCopyValue(person,
kABPersonFirstNameProperty);
self.firstName.text = name;
name = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
self.lastName.text = name;
[self dismissModalViewControllerAnimated:YES];
return NO;
}
Thank you for your help!
It sounds like you are using ARC.
ARC forbids standard casts between pointers to Objective-C objects and pointers of other types, including pointers to CoreFoundation objects.
The following code, which is correct under manual memory management, does not compile with ARC:
To make it compile with ARC, you need to annotate the cast. See bridged casts.
The
__bridge_transferannotation moves the value into ARC and transfers ownership, i.e., it tells ARC that this object is already retained, and that ARC doesn’t need to retain it again.