Most of the classes like NSString NSArray and so on, have the convenience constructors like NSString string and NSArray array which return the autoreleased objects NSNumberFormatter doesn't have any convenience constructors. So, you can send a autorelease message to let it autoreleased when the autorelease pool drains.
Most of the classes like NSString, NSArray, and so on, have the convenience constructors like, NSString string and NSArray array which return the autoreleased objects. NSNumberFormatter doesn't have any convenience constructors. So, you can send a autorelease message to let it autoreleased when the autorelease pool drains.
NSNumber *theBalance = NSNumberFormatter alloc init autorelease numberFromString: textField text; If you want to retain(own) the reference of the object, you can omit the autorelease and release it later when you are done with it. You do it like this, NSNumberFormatter *numberFormatter = NSNumberFormatter alloc init; NSNumber *theBalance = numberFormatter numberFromString: textField text; // Later... somewhere in your code... numberFormatter release; I know the above is not a detailed explanation. I'd suggest you to read this post by which, I hope, you would get some clear idea about memory management!
Autorelease appears to be the information I was missing, which combined with thinking like a C++ programmer sent me off on a bit of a tangent. Autorelease just says "at some point in the future call release" where "some point" is guaranteed to be after the end of the current statement (sequence point? ) right?
– awoodland Oct 13 '11 at 12:10 1 @awoodland: Yes, it's exactly like that. In Cocoa we often speak of ownership, and we say that with release and autorelease we give up ownership of an object: immediately with release, sometime later with autorelease. Typically, autoreleased object are freed at each runloop iteration.
You might be interested in reading Let's build NSAutoreleasePool by Mike Ash to gain understanding what's really happening. – DarkDust Oct 13 '11 at 12:14 1 @awoodland, Here "some point" doesn't mean the end of current statement. It means that the object will be released whenever the current autorelease pool is destroyed.
Its guaranteed that the object will not be released before the execution of the current method (where you have created/autoreleased the object) is over. You will get problem only when you try to access the object outside the method where you have created/autoreleased the object. – EmptyStack Oct 13 '11 at 12:25.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.