0
votes

I am writing an application using Core Data, with this attribute in one entity:
@property (nonatomic, retain) NSString * mesa;

I have a problem passing the value from a JSON processed dictionary:
local.mesa =[locales [0] valueForKey:@"mesa"];

I am obtaining this error:
'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "mesa"; desired type = NSNumber; given type = __NSCFString; value = Salón 2.'

This indicates to me that the desired type is NSNumber, but the attribute is declared as NSString in the xcdatamodel and the class.

It is possible that the first declaration of the attribute was NSNumber, and it seems as if he had not changed.

Any ideas?

2
make sure it is NSString in the model, then regenerate the NSManagedObject file. You shouldn't manipulate the core data generated NSmanagedObject files directlyWilliam Falcon
also, if you changed the data type of an item in the model you should clean the build and delete any existing database file before running again.Wain
Thanks, but how I can regenerate the NSManagedObject file?. I have cleaned and built the product, but i have not deleted any databasePaco
I solved it uninstalling the app from the simulator, and after, following this thread: stackoverflow.com/questions/12617585/… recreating the right hierarchy of data model. Thanks everybodyPaco
What if the app is in app-store? User will just update the app and not delete it. How to resolve in this case?Laxy

2 Answers

1
votes

If the schema had a nsnumber before in the simulator delete your app from the simulator so a new core database is created with nsstring in that variable.

0
votes

I forget to close this, sorry. Like I said before:

I solved it uninstalling the app from the simulator, and after, following this thread: Cannot create an NSPersistentStoreCoordinator with a nil model after deleting app from device recreating the right hierarchy of data model. Thanks again