Dealloc objects of another class?

If you init copy or new them you'll have to deallocate them if you put an autorlease with the allocation then they will be autoreleased.

If you init copy or new them you'll have to deallocate them if you put an autorlease with the allocation then they will be autoreleased for example Foo *foo = Foo alloc init; //you'll have release it somewhere yourself And Foo *foo = Foo alloc init autorelease;// this will be autreleased.

The simple case is : if you use init, you are responsible for releasing it, either by calling release or by calling autorelease. E.g. NSString *myString = NSString alloc init; // You need to release this ... myString release; // Now it's released - don't use it again!

Or if you are going give it to someone else NSString *myString = NSString alloc init; // This needs releasing ... return myString autorelease; // You are finished with it but someone else might want it However, there's a few other cases. NSString *myString = NSString stringWithFormat:@"hi"; This object is in the autorelease pool already - don't release it! NSString *secondString = myString copy; This object needs releasing - it is not autoreleased.

Rule of thumb : Anything with init, copy or new in the name - you made it, you release it. Anything else will be autoreleased.

1 The Rule of thumb is not quite correct: it's not the init but the alloc that demands a release, additionally it's missing new. – danyowdee Jan 28 at 16:25 Blast, I always forget new :( I've edited my answer, thanks! – deanWombourne Jan 29 at 10:59.

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.

Related Questions