• 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: object Properties released or autoreleased?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: object Properties released or autoreleased?


  • Subject: Re: object Properties released or autoreleased?
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 15 Jan 2009 13:06:31 +0100


On 14.01.2009, at 19:19, Andy Lee wrote:

On Jan 14, 2009, at 12:56 PM, Memo Akten wrote:
it is sent a release. if you want to autorelease you can create your own setter:

- (void) setThing: (NSObject*) newThing {
	[thing autorelease];
	//or
	[thing release]; (default)

	thing = [newThing retain];
}

Memo might have meant this code to give a general idea, not to be taken verbatim, but for the record: if you choose the release option, you need to handle the case where thing == newThing on entry. Otherwise you run the risk of dealloc'ing the object prematurely.



hm, this would mean

@property (retain) NSObject* thing;
...
self.thing = self.thing;

that the assignment will not be implemented propperly if the setter has been @synthesized, and the possible call of -dealloc/-finalize method will cause undefined behavior.

If the language and compiler cannot handle basic patterns correctly, why do we have @synthesize at all?
I haven't tested it yet, but I strongly believe it will work exactly as we would implement these basic patterns ourself. Please, can anybody confirm this?


Where is the standardized formal language spezification, anyway? (rhetoric question).

Andreas


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: object Properties released or autoreleased?
      • From: Andreas Grosam <email@hidden>
  • Prev by Date: Re: Compile-only build option?
  • Next by Date: Re: object Properties released or autoreleased?
  • Previous by thread: Inline errors on XCode 3.1.1 and libgmp 4.2.4
  • Next by thread: Re: object Properties released or autoreleased?
  • Index(es):
    • Date
    • Thread