Reputation: 12797
I am bothered by the following code snippet in my program.
If I write
mo=[[myObj alloc] init];
it fails, but if I write
mo=[myObj alloc];
mo=[mo init];
it works. These two methods are supposed to be equivalent but somehow I am messing up. Any light?
Clarifications:
myObj is the name of a class
It fails by trying to allocate for a different kind of object, failing to find the right methods and finally crapping out far from the initialization.
Upvotes: 1
Views: 284
Reputation: 21254
I think this may happen only when the -(id)init
method is overwriten wrong in the myObj
Class.
Maybe you don't return self;
or you don't have the returning type (id)
. If none of this is right, please provide more details about how the -(id)init
method is implemented.
Upvotes: 3