【问题标题】:RestKit RKObjectLoader objectLoader didLoadObjects failed on deviceRestKit RKObjectLoader objectLoader didLoadObjects 在设备上失败
【发布时间】:2012-03-07 11:35:38
【问题描述】:

我正在使用 RestKit,但遇到了一个问题。我已经尝试了很多方法来解决这个问题,但没有成功。 :)

- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
    NSLog(@"objects count: %d.", [objects count]);
    NSLog(@"editions count: %d.", [editions count]);
    [editions release];
    editions = [objects retain];
    NSLog(@"objects count: %d.", [objects count]);
    NSLog(@"editions count: %d.", [editions count]);
    Edition *edition = [objects objectAtIndex:0];
    NSLog(@"edition title: %@.", [edition title]);
}

上面代码的控制台是:

2012-03-07 18:02:58.477 AppName[2870:207] objects count: 1.
2012-03-07 18:02:58.478 AppName[2870:207] editions count: 0.
2012-03-07 18:02:58.479 AppName[2870:207] objects count: 1.
2012-03-07 18:02:58.479 AppName[2870:207] editions count: 1.
2012-03-07 18:02:58.480 AppName[2870:207] *** -[NSCFArray title]: unrecognized selector sent to instance 0x1ada60
2012-03-07 18:02:58.481 AppName[2870:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray title]: unrecognized selector sent to instance 0x1ada60'
2012-03-07 18:02:58.483 AppName[2870:207] Stack: (
    827948665,
    859256445,
    827961723,
    827960065,
    827553488,
    13253,
    166217,
    827523067,
    873795279,
    827497493,
    827495649,
    865677531,
    865677703,
    806360113,
    806353243,
    10471,
    10396
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
Program received signal:  “SIGABRT”.

但是,它可以在模拟器上运行:

2012-03-07 18:24:20.215 AppName[46315:207] objects count: 4.
2012-03-07 18:24:20.215 AppName[46315:207] editions count: 0.
2012-03-07 18:24:20.216 AppName[46315:207] objects count: 4.
2012-03-07 18:24:20.216 AppName[46315:207] editions count: 4.
2012-03-07 18:24:20.216 AppName[46315:207] edition title: Some String.

请帮助.. 任何形式的回复将不胜感激。谢谢。

ps:我还运行了 RKTwitter 示例。结果是一样的!它在模拟器上很棒,但在设备上却出现了同样的错误。

pps:我已经为 master (Xcode4) 和 0.9-stable(Xcode3) 分支尝试了 RKTwitter 示例。结果是一样的。在模拟器上没问题,但在设备上失败了。

【问题讨论】:

    标签: objective-c arrays object restkit nsexception


    【解决方案1】:

    我在移植低于 10.7 的应用程序时遇到了同样的问题,似乎发生的事情是将我的 NSArray *objects 包装在第二个数组中

    (
     (
       <ITEM>
       <ITEM>
       <ITEM>
     )
    )
    

    这仅发生在我的 10.6 目标上,因此获取真实对象就像查看数组的第一个索引是否是索引然后使用它一样简单。我猜它是一个错误/怪癖。或者我做错了什么,谁知道呢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多