Incompatible pointer types initializing 'NSEntityDescription *' with an expression of type '__kindof NSManagedObject * _Nonnull'

1k views Asked by At

every thing works fine but i get this notice

and try to search to find solution but with no luck

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
NSManagedObjectContext *context = appDelegate.managedObjectContext ;
NSString *title = [[Picker delegate]pickerView:Picker titleForRow:[Picker selectedRowInComponent:1] forComponent:1];

NSEntityDescription *entity = [NSEntityDescription insertNewObjectForEntityForName:@"History" inManagedObjectContext:context];
1

There are 1 answers

2
Tom Harrington On BEST ANSWER

In this line:

NSEntityDescription *entity = [NSEntityDescription insertNewObjectForEntityForName:@"History" inManagedObjectContext:context];

The method you're calling returns an instance of NSManagedObject. You are assigning it to a variable of type NSEntityDescription. That's what the message is telling you.