Question

I am using RestKit and stuck with a problem. I've tried quite a lot of things to solve this, but return no success. :)

- (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]);
}

The console for above code is:

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”.

However, it works on the simulator:

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.

Please help.. Any kind of responses will be appreciated. Thank you.

ps: I've also run the RKTwitter sample. The result is same! It was great on simulator but resulting same kind of error on device.

pps: I've tried the RKTwitter sample for master (Xcode4) and for 0.9-stable(Xcode3) branch. The result is same. It was ok on simulator, but failed on devices.

Was it helpful?

Solution

I had the same issue porting an app below 10.7, what seems to happen is it was wrapping my NSArray *objects in a second array

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

This only happened on my 10.6 target though, so getting the real objects was as simple as seeing if the first index of the array was an index and then using that. Its a bug/quirk I guess. Or I'm doing something wrong, who knows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top