• 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: alloc, init and autorelease/release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: alloc, init and autorelease/release
      • From: jkp <email@hidden>
References: 
 >alloc, init and autorelease/release (From: Felix Schwarz <email@hidden>)

  • Prev by Date: Core Data - Initializing with standard data
  • Next by Date: Re: Core Data - Initializing with standard data
  • Previous by thread: alloc, init and autorelease/release
  • Next by thread: Re: alloc, init and autorelease/release
  • Index(es):
    • Date
    • Thread