0

In my simple project I have a core data model file and in this model file I have an entity called "Target", I created a subclass of NSManagedObject to this entity so I can persist data. So now I have a .h and .m Target class files with just two attributes:

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>


@interface Target : NSManagedObject

@property (nonatomic, retain) NSString * body;
@property (nonatomic, retain) NSDate * time;

@end

Now I want to add to this class 2 more properties so I read about it and gave it few tries with some techniques but each one will give me the same error which is:

enter image description here

How do I get rid of the error "The model used to open the store is incompatible with the one used to create the store"?

John83
  • 143
  • 5
nick shmick
  • 905
  • 1
  • 9
  • 25
  • Don't post screenshot of your error, show us directly the text error. http://stackoverflow.com/questions/8881453/the-model-used-to-open-the-store-is-incompatible-with-the-one-used-to-create-the – Larme Feb 12 '15 at 10:05
  • Those 2 properties are you adding at runtime? – nagarajan Feb 12 '15 at 10:06

3 Answers3

1

Whenever u modify the entity like adding attributes/removing/modifying u need to remove the app from simulator/device and then u need to run the app to avoid crash..

Else If ur app is in App Store and If u want to add more properties to existing app u need to do Core Data Migration..

Refer below links

http://www.informit.com/articles/article.aspx?p=2150667&seqNum=2

http://code.tutsplus.com/tutorials/core-data-from-scratch-migrations--cms-21844

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html

Hope it helps..

Vidhyanand
  • 5,369
  • 4
  • 26
  • 59
1

Try deleting ur application from simulator/device. And try to build and run it again.

Dheeraj Singh
  • 5,143
  • 25
  • 33
0

Try to uninstall application from your simulator/device then install again. This crush happening because of what type of migration or store option your are giving while adding NSPersistentStore with NSPersistentStoreCoordinator object.

Try to read about migration from

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/index.html#//apple_ref/doc/constant_group/Migration_Options

nagarajan
  • 474
  • 3
  • 21