3. Lightweight migration can do
• Adding or removing an entity, attribute or relationship
• Make an attribute non-optional with a default value
• Making a non-optional attribute optional
• Renaming an entity or attribute using a renaming identifier
13年8月15⽇日星期四
12. Run - Crash
Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error
134100.)" UserInfo=0x834a9f0 {metadata={
NSPersistenceFrameworkVersion = 419;
NSStoreModelVersionHashes = {
Event = <5431c046 d30e7f32 c2cc8099 58add1e7 579ad104 a3aa8fc4 846e97d7 af01cc79>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "E8AAA7FE-4F73-4D13-B7F2-451C0F487E21";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}, {
metadata = {
NSPersistenceFrameworkVersion = 419;
NSStoreModelVersionHashes = {
Event = <5431c046 d30e7f32 c2cc8099 58add1e7 579ad104 a3aa8fc4 846e97d7 af01cc79>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "E8AAA7FE-4F73-4D13-B7F2-451C0F487E21";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";
}
13年8月15⽇日星期四
14. Crash again
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'executeFetchRequest:error: A fetch request must
have an entity.'
13年8月15⽇日星期四
15. Change Entity name
• MasterViewController.m
- (NSFetchedResultsController *)fetchedResultsController
{
if (_fetchedResultsController != nil) {
return _fetchedResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Record"
inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
// ignore ...
}
13年8月15⽇日星期四
17. Delete all data first
• remove original codes
• MasterViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
! // Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
// UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self
action:@selector(insertNewObject:)];
// self.navigationItem.rightBarButtonItem = addButton;
}
13年8月15⽇日星期四
31. Delete some version
• Remove .xcdatamodeld (Remove Reference Only)
• Open project in the finder
• find out .xcdatamodeld
• Right-click -> Show Package Contents
• Delete what you want to delete
13年8月15⽇日星期四