• 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: Releasing ivars in -didTurnIntoFault. Should set to nil?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing ivars in -didTurnIntoFault. Should set to nil?


  • Subject: Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
  • From: "Georg C. Brückmann" <email@hidden>
  • Date: Thu, 13 Aug 2009 12:45:08 +0200

Quincey –

In practice, the delegate is often -- independently of its role as delegate -- the *owner* of the referencing object (e.g. a window controller that is a delegate of a table view loaded from a nib file is the owner of the nib file's contents, including, directly or indirectly, the table view). However, in that case, there's no reason why the owner would relinquish ownership of the owned object during a delegate method.

Yes, those are the cases I was referring to.

Unless I'm missing something obvious.


Consider NSURLConnection’s -connectionDidFinishLoading: delegate method:

	- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
		// Do stuff
		[myReferenceToTheConnection release];
		myReferenceToTheConnection = nil;
	}

Now, in the case of NSURLConnection there’s no need to ensure the connection object remains valid until the current autorelease pool gets drained (aka at the end of the current run loop cycle). But one doesn’t always know how a specific class is implemented, and in that case autoreleasing can help you prevent malloc errors.

I admit these are probably edge cases, but I’ve stumpled upon them. So while you may consider this overly cautious, writing such a macro takes about ten seconds – time that is easily saved when using the macro as it saves you one line of code each time you use it.

– Georg_______________________________________________

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: Releasing ivars in -didTurnIntoFault. Should set to nil?
      • From: Quincey Morris <email@hidden>
References: 
 >Releasing ivars in -didTurnIntoFault. Should set to nil? (From: Jerry Krinock <email@hidden>)
 >Re: Releasing ivars in -didTurnIntoFault. Should set to nil? (From: "Sean McBride" <email@hidden>)
 >Re: Releasing ivars in -didTurnIntoFault. Should set to nil? (From: Dave Keck <email@hidden>)
 >Re: Releasing ivars in -didTurnIntoFault. Should set to nil? (From: "Georg C. Brückmann" <email@hidden>)
 >Re: Releasing ivars in -didTurnIntoFault. Should set to nil? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Cocoa-dev Digest, Vol 6, Issue 1146
  • Next by Date: NSArrayController - compound values vs Select Inserted Objects
  • Previous by thread: Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
  • Next by thread: Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
  • Index(es):
    • Date
    • Thread