CakePHPでいかのようなエラーが出た場合、
core.phpの
Configure::write('debug', 0);
を0から1に変更したらなおった
(BOOL)resetDatastore
{
[[self managedObjectContext] lock];
[[self managedObjectContext] reset];
NSPersistentStore *store = [[[self persistentStoreCoordinator] persistentStores] lastObject];
BOOL resetOk = NO;
if (store)
{
NSURL *storeUrl = store.URL;
NSError *error;
if ([[self persistentStoreCoordinator] removePersistentStore:store error:&error])
{
[[self persistentStoreCoordinator] release];
__persistentStoreCoordinator = nil;
[[self managedObjectContext] release];
__managedObjectContext = nil;
if (![[NSFileManager defaultManager] removeItemAtPath:storeUrl.path error:&error])
{
NSLog(@"\nresetDatastore. Error removing file of persistent store: %@",
[error localizedDescription]);
resetOk = NO;
}
else
{
//now recreate persistent store
[self persistentStoreCoordinator];
[[self managedObjectContext] unlock];
resetOk = YES;
}
}
else
{
NSLog(@"\nresetDatastore. Error removing persistent store: %@",
[error localizedDescription]);
resetOk = NO;
}
return resetOk;
}
else
{
NSLog(@"\nresetDatastore. Could not find the persistent store");
return resetOk;
}
}
+ (void)swapInstanceMethodsForClass: (Class) cls selector: (SEL)sel1 andSelector: (SEL)sel2 {Method method1 = class_getInstanceMethod(cls, sel1);Method method2 = class_getInstanceMethod(cls, sel2);method_exchangeImplementations(method1, method2);}method_exchangeImplementations()を使えばこのようにクラスメソッドを差し替えられるのでテストでは便利。