Reputation: 10314
In one of my classes I have an -(id) init
method. The first thing that happens in that method is a call to [super init]
This was all fine, but I recently imported my code which was quite old into a new xcode project. I get an error on this line:
error: Automatic Reference Counting Issue: The result of a delegate init call must be immediately returned or assigned to 'self'
Why is this error occurring? is it because this is depreciated under the ARC system? or something else?
Upvotes: 0
Views: 1531
Reputation: 6877
This worked out to me:
need assign some thing in self.
-(id) init {
self = [super init];
return self;
}
Upvotes: 0
Reputation: 16941
It worked before for you because LLVM is much more strict than GCC was before. GCC didn't detect the error and as @vakio pointed out in his comment, it worked because somewhere up in the chain, self = [super init]
was present. LLVM detects this error during compile time and prevents you from compiling the incorrect code.
Upvotes: 1
Reputation: 5722
How did you do it with the old system? You're expected (on both versions) to do
self = [super init];
if (self) ...
return self;
Upvotes: 3