Re: alloc, init and autorelease/release
Re: alloc, init and autorelease/release
- Subject: Re: alloc, init and autorelease/release
- From: j o a r <email@hidden>
- Date: Sat, 22 Oct 2005 18:35:30 +0200
On 22 okt 2005, at 15.32, Felix Schwarz wrote:
Code sample 1:
Valid. I would have used release, and not autorelease, but it's not
very important. It just seems pointless to use autorelease there.
Code sample 2:
Invalid, unless you call [super init] in "-someOtherInit:", in which
case it's OK.
Same thing about release vs. autorelease applies here too.
Or, in other words, is it ok to autorelease and or release an
object right after "alloc"ation, before it was "init"ialized?
Yes, I guess it is, but I wouldn't do:
I.e. is it ok to do
id someObj = [SomeObj alloc];
[someObj release];
or
id someObj = [SomeObj alloc];
[someObj autorelease];
Simply because it breaks the rule that you should always alloc+init
on the same row.
I also don't really see when you would want to do the above?
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden