ABAddressBookRef question
ABAddressBookRef question
- Subject: ABAddressBookRef question
- From: "David F." <email@hidden>
- Date: Fri, 23 Apr 2010 18:01:23 -0600
Does an ABAddressBookRef remain valid after the AddressBook that it came from is released?
Let's say I have a little object that holds onto an address:
@interface AddressInfo : NSObject {
ABRecordID contactRecordID;
ABMultiValueIdentifier addressID;
}
@end
Now let's say I want to open an ABPersonViewController to edit the address. Can I get the ABAddressBookRef of the person, release the address book and show the ABPersonViewController (as in Code Sample 1) or does the address book need hang around (as in Code Sample 2)?
--Code Sample 1--
// self.address is an AddressInfo instance
ABAddressBookRef addressBook = ABAddressBookCreate();
ABPersonViewController *personView = [ABPersonViewController new];
personView.personViewDelegate = self;
personView.displayedPerson =
ABAddressBookGetPersonWithRecordID(addressBook, self.address.contactRecordID);
personView.displayedProperties =
[NSArray arrayWithObject: [NSNumber numberWithInt: kABPersonAddressProperty]];
personView.allowsEditing = TRUE;
[self.navigationController pushViewController: personView animated: TRUE];
CFRelease(addressBook);
[personView release];
--Code Sample 2--
// self.address is an AddressInfo instance
ABAddressBookRef addressBook = ABAddressBookCreate();
ABPersonViewController *personView = [ABPersonViewController new];
personView.personViewDelegate = self;
personView.addressBook = addressBook;
personView.displayedPerson =
ABAddressBookGetPersonWithRecordID(addressBook, self.address.contactRecordID);
personView.displayedProperties =
[NSArray arrayWithObject: [NSNumber numberWithInt: kABPersonAddressProperty]];
personView.allowsEditing = TRUE;
[self.navigationController pushViewController: personView animated: TRUE];
CFRelease(addressBook);
[personView release];
Thanks,
David F.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden