Reputation: 35
When I write:
MyClass *obj = [[MyClass alloc]init];
I can split in 2 parts:
[MyClass alloc]
--->> produce something
[theProduct init];
So alloc is a Class methods and being init an instance method i suppose that it must be called on an instance...in this case the result of [MyClass alloc]
.
I'm really confused about that.
Are my conjectures correct?
Upvotes: 0
Views: 55
Reputation: 5558
Familiar with C++? +alloc
= new
. -init…
= constructor method.
Upvotes: 0
Reputation: 43472
+alloc
allocates and zeroes the memory for an instance of a class. This instance is uninitialized—it's not ready to be used as an object until you initialize it with -init
or related.
Upvotes: 4