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
initmethod that was posted in the question was in the wrong form. Theinitmethod should (usually) have the form: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.