• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
ABAddressBookRef question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: UIResponder Woes
  • Next by Date: Newbie Q (Distributed Objects)
  • Previous by thread: Re: 'Build and Analyze' with XCODE 3.2.2
  • Next by thread: Newbie Q (Distributed Objects)
  • Index(es):
    • Date
    • Thread