iphone - Why should I send -autorelease to my instance variable in my setter method, rather than -release? -


The applet is doing this in a setter method for a frequency variable mainSprocket:

   

- (zero) setMainSprocket: (Sprocket *) newSprocket {[mainSprocket autorelease]; MainSprocket = [new esprocet maintained]; Return; }

Why do they send -autoletise and not-stroke? Is there a bad repetition here? Actually this should not be (for my understanding), because -release only says that the existing object can not be organized by the included mainSprocket, that is used by that frequency variable. For the case that someone else is still really interested in that object, that method can keep it, is not it? So- should I work properly?

They are autorelease here newSprocket And main suspic can be the same object. Before retaining to the next line, you can ignore the call object on release , while the action will not be taken on autorelease until the AutoRevenue Pool closes the event loop.

Consider this scenario:

  Sprocket * mySprocket = [Sprocket spacelySprocket]; [SprocketManager set MainSprocket: mySprocket]; Sprocket * other pointTemos MySpace = mySprocket; [Sprocketmanager SetmanSprocket: Second PointTomosaccept];  

If the mainSprocket was not autocorrect then the last line would be a problem. Another conference you can sometimes refer to the setter code, which is the same Does the thing:

  - (zero) setmanprint: (spocket *) newSprocket {if (newSprocket! = MainSprocket) {[mainSprocket release]; MainSprocket = [new esprocet maintained]; }}  

I will leave others to comment on this, which is more suitable or aesthetically pleasing: -)


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -