【问题标题】:fetchcontroller is not getting value in facebook chat ios appfetchcontroller 在 facebook 聊天 ios 应用程序中没有获得价值
【发布时间】:2012-09-03 07:27:37
【问题描述】:

我已使用以下方法在我的 FBChat 应用程序中注销时删除了 Core Data 中存储的所有条目。

//delete persistance.......         



 if ([__persistentStoreCoordinator persistentStores] == nil)
     return;

 [self.managedObjectContext reset];
 [self.managedObjectContext lock];

 NSPersistentStore *store = [[self.persistentStoreCoordinator persistentStores] lastObject];

 if (![self.persistentStoreCoordinator removePersistentStore:store error:&error]) {
     NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
     abort();
 }  


// Delete file

 if ([[NSFileManager defaultManager] fileExistsAtPath:store.URL.path]) {
     if (![[NSFileManager defaultManager] removeItemAtPath:store.URL.path error:&error]) {
         NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
         abort();
     } 
 }

 __persistentStoreCoordinator = nil;

 __persistentStoreCoordinator = [self persistentStoreCoordinator];
 [self.managedObjectContext unlock];

但是当我再次登录时,fetchcontroller 没有得到值。我在注销时设置了fetchcontroller=nil。 fetchcontroller 的委托方法在登录时被调用。

如果有人有想法,请帮助我。提前致谢

【问题讨论】:

    标签: ios5 core-data xcode4.2 nsfetchrequest nsfetchedresultscontroller


    【解决方案1】:

    这是预期的行为。删除所有内容后,您将无法获得价值。如果您的获取结果控制器是延迟创建的(代码未显示,但这通常是设计模式),它会在需要时自行创建。

    这里没有惊喜。

    【讨论】:

    • 感谢您的回答。我使用了另一种方法来清除核心数据。现在它工作正常
    猜你喜欢
    • 2014-05-04
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    相关资源
    最近更新 更多