I have a core data NSManagedObject named CD_CoffeeShop . When i allocated a variable
CD_CoffeeShop *temp_CS = [ CD_CoffeeShop new]
and try to pass a value to it,
[temp_CS setCoffeeShopId:[NSNumber numberWithInt:coffeeShop.Id]];
(the variable coffeeShopId of temp_CS is a NSNumber)
i get an error that says :
Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason: ‘-[CD_CoffeeShop
setCoffeeShopId:]: unrecognized selector sent to instance 0x6b34040’
What can it be ?
Have you read the Core Data Programming guide? You do not instantiate core data objects with the NSObject methods. You either obtain them with a fetch request if they exist already or you use NSEntityDescription to insert a new object into the context.
Definitely don’t use
new.