Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

teguh123

macrumors member
Original poster
Mar 22, 2011
62
0
Why do we use



NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
Why not

NSAutoreleasePool * pool = [NSAutoreleasePool new];
 
Well, mostly, alloc init, is for creating the memory part where it's gonna put it, like every other object (nearly). there is a biiig explenation about this, i'm sure some of these guys can exactly tell you, it's something with bits on the heap stack, and blah x) But it all comes down to memory management.
 
Well, mostly, alloc init, is for creating the memory part where it's gonna put it, like every other object (nearly). there is a biiig explenation about this, i'm sure some of these guys can exactly tell you, it's something with bits on the heap stack, and blah x) But it all comes down to memory management.

I thought new is just a short for alloc init

Both seems to work just fine. It's just choice it seems
 
That's right. Functionally alloc/init and new are the same. It's a style difference. new is not popular. Most old timers prefer to use alloc/init because it's more clear what's going on.
 
Also, a lot of times there are extensions to init (for example, initWithString:) but no corresponding extension to new.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.