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
Also is there any case where we call alloc and not init after that?

What confuses me is things like

self= [super init]

Basically, if self is a pointer to the class, we're tell self to point to the address described by [super init]

The problem with that is self should already point to whatever address returned by alloc right?

So why change it?
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
In any instance method (-), self refers to the instance. In any class method (+), self refers to the class. Always call an init method after calling +alloc. The reason to set it is that some classes play tricks in -init and don't return the same object that +alloc did.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.