【问题标题】:assignObject:toPersistentStore: breaking out of a loopassignObject:toPersistentStore: 跳出循环
【发布时间】:2015-04-26 22:52:23
【问题描述】:

在我的一个 iOS 应用程序中,我有以下代码,它本身在一个循环中:

NSLog(@"Before context assignObject:toPersistentStore:");
[context assignObject:newXplainItem toPersistentStore:theStore];
NSLog(@"After context assignObject:toPersistentStore:");

第一个 NSLog 被执行,但第二个永远不会。 并且循环的其余部分也永远不会执行(就像有一个 break 语句一样)。 但应用不会崩溃。

第二行 (assignObject:toPersistentStore:) 看起来像我在同一程序中使用的许多其他类似行。

任何人都可以猜测可能出了什么问题? 我想我在这里提供的信息是有限的。但我真的不知道还能写什么。

【问题讨论】:

  • 可能是一个可能被堆栈忽略的异常。在那里设置一个断点,看看它会把你带到哪里。
  • 也许吧。请参阅我自己的答案。

标签: ios core-data persistent-storage


【解决方案1】:

以防其他人遇到同样的问题。这是我做错的: 在数据模型中,我忘记将实体分配给正确的商店。 奇怪的是,它不会产生任何错误。

【讨论】:

    猜你喜欢
    • 2021-08-31
    • 2012-01-16
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    相关资源
    最近更新 更多