Search
Rich's Mad Rants
Powered by Squarespace

Creating iOS 5 Apps Discussion > Pages 234 & 250 - Getting warning on designated initializer

When I run the app, it compiles and runs fine. However, I get a warning (with a blue icon that I haven't seen before: http://snurl.com/blueicon)...

Missing "self = [(super or self) init...]"
Returning 'self' while it is not set to the result of '[(super or self) init...]'

When I change initWithWeightEntryArray: to set self first instead of nesting it in the if block, the warning goes away....

- (id)initWithWeightEntryArray:(NSArray *)weightEntries
{
self = [super init];

if (self)
{
[self processArray:weightEntries];
}

return self;
}

December 28, 2011 | Unregistered CommenterScott

The blue icon is probably a warning from the static analyzer, if you turned it on.

Did you have two pairs of parenthesis around self=[super init]? That should get rid of the warning.


- (id)initWithWeightEntryArray:(NSArray*)weightEntries {
if ((self = [super init])) {
[self processArray:weightEntries];
}
return self;
}

December 29, 2011 | Registered CommenterRichard Warren