0

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?

4

2 に答える 2

4

+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.

于 2012-06-28T13:57:38.130 に答える
0
于 2012-06-28T13:57:54.830 に答える