• 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
Re: memory management issue?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory management issue?


  • Subject: Re: memory management issue?
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 1 Feb 2008 20:38:14 +0000


On 1 Feb 2008, at 19:33, Steven Crosley wrote:

Looks like it was an issue with the setAddressBook function. Works like a charm now, and I think I more fully understand how memory management works. Thanks again for all your help!

Before suggestions:

- (void)setAddressBook
{
	book = [ABAddressBook sharedAddressBook];
	person = (ABPerson *)[book recordForUniqueId:[self uid]];
}


After suggestions:

- (void)setAddressBook
{
	[book release];
	[person release];
	book = [[ABAddressBook sharedAddressBook] retain];
	person = (ABPerson *)[[book recordForUniqueId:[self uid]] retain];
}

There's a big possible flaw here. What if the old and new book or person objects are the same? You'll release the object, and if that deallocs it, the next code will attempt to retain a dead object. Admittedly in this particular case it's pretty unlikely, but it's good general practice for accessor methods of all kinds.


On Feb 1, 2008, at 12:51 PM, j o a r wrote:


On Feb 1, 2008, at 10:29 AM, Steven Crosley wrote:

[NSCFString valueForProperty:]: unrecognized selector sent to instance 0x1b90e0


Sounds like a message sent to a deallocated object, something that using NSZombieEnabled would help you troubleshoot. Give it a try!

j o a r



_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: memory management issue?
      • From: Chris Suter <email@hidden>
References: 
 >memory management issue? (From: Steven Crosley <email@hidden>)
 >Re: memory management issue? (From: Chris Suter <email@hidden>)
 >Re: memory management issue? (From: Steven Crosley <email@hidden>)
 >Re: memory management issue? (From: j o a r <email@hidden>)
 >Re: memory management issue? (From: Steven Crosley <email@hidden>)

  • Prev by Date: Re: Need some help with fetch requests
  • Next by Date: Re: Need some help with fetch requests
  • Previous by thread: Re: memory management issue?
  • Next by thread: Re: memory management issue?
  • Index(es):
    • Date
    • Thread