Whats wrong with this code under ARC? I get above error:
- (Moment *)initMoment:(BOOL)insert {
if (insert) {
self.moment = [NSEntityDescription insertNewObjectForEntityForName:@"Moment" inManagedObjectContext:self.managedObjectContext];
} else {
self.moment = [NSEntityDescription insertNewObjectForEntityForName:@"Moment" inManagedObjectContext:nil];
}
return self.moment;
}
The init
method that was posted in the question was in the wrong form. The init
method should (usually) have the form:
-(id)initWithParams:(BOOL)aBoolParam {
if (self = [super init]) {
//do stuff
}
return self;
}
The problem with code above was that it was done as a class method, so if the poster wanted to do this he had to do moment = [[Moment alloc] init]
and return it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With