【发布时间】:2011-07-27 23:59:19
【问题描述】:
为什么每次我在我的 NSManagedObjectContext 上调用save:
-(NSManagedObjectContext*)managedObjectContext {
NSMutableDictionary* threadDictionary = [[NSThread currentThread] threadDictionary];
NSManagedObjectContext* backgroundThreadContext = [threadDictionary objectForKey:RKManagedObjectStoreThreadDictionaryContextKey];
if (!backgroundThreadContext) {
backgroundThreadContext = [self newManagedObjectContext];
[threadDictionary setObject:backgroundThreadContext forKey:RKManagedObjectStoreThreadDictionaryContextKey];
[backgroundThreadContext release];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mergeChanges:)
name:NSManagedObjectContextDidSaveNotification
object:backgroundThreadContext];
}
return backgroundThreadContext;
}
- (NSError*)save {
NSManagedObjectContext* moc = [self managedObjectContext];
NSError *error = nil;
@try {
if (![moc save:&error]) { //breakpoint in here
//some code
}
该应用程序似乎一直在等待并且再也没有回来恢复它的执行?这就是我在video 中的意思。这可能是因为实体/关系模型有问题吗?
这是泄漏工具的屏幕截图,我没有看到任何泄漏,但似乎应用程序正在分配一些积累的东西:
【问题讨论】:
-
Instruments 可以提供帮助,在instruments 下运行应用程序,看看发生了什么。
标签: iphone objective-c ipad core-data