xcodecore-datansentitydescription

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


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];

Solution

  • 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.