Namespace collision in 1.01 vs broken JSON parser in 1.1 -- help!

8 views
Skip to first unread message

Aaron Russell

unread,
Apr 30, 2011, 7:41:04 AM4/30/11
to objectiv...@googlegroups.com
Seems like I'm stuck between a rock and a hard place. I have a resource in my Rails app called "response". Unfortunately, this name clashes with ObjectiveResource's Response class. I tried upgrading to 1.1 (yfactorial's 1.1, that is) and using the new [ObjectiveResourceConfig setLocalClassesPrefix:@"ABC"]; notation to define a local prefix for my app, but now the JSON parser has an exception that crashes my app.

Here's what's on the console after my app tries reading in some JSON:

[Session started at 2011-04-30 12:16:32 +0100.]
2011-04-30 12:16:35.177 MyApp[8097:1b03] GET -> http://myapp.tld/conversations.json
2011-04-30 12:16:35.835 MyApp[8097:1b03] <= [{"conversation": {"created_at": "2011-03-28T07:07:39Z", "recipient_email": null, "creator_resolved": false, "updated_at": "2011-03-28T07:08:44Z", "creator_archived": false, "recipient_id": 3, "id": 58, "declined": null, "user_id": 1, "recipient_resolved": false, "creator_deleted": false, "recipient_deleted": false, "recipient_archived": false, "real_time_user": null}}, {"conversation": {"created_at": "2011-03-28T07:09:42Z", "recipient_email": null, "creator_resolved": false, "updated_at": "2011-03-28T07:10:02Z", "creator_archived": false, "recipient_id": 1, "id": 60, "declined": null, "user_id": 3, "recipient_resolved": false, "creator_deleted": false, "recipient_deleted": false, "recipient_archived": false, "real_time_user": null}}, {"conversation": {"created_at": "2011-04-09T20:30:19Z", "recipient_email": null, "creator_resolved": false, "updated_at": "2011-04-09T20:30:19Z", "creator_archived": false, "recipient_id": null, "id": 61, "declined": null, "user_id": 3, "recipient_resolved": false, "creator_deleted": false, "recipient_deleted": false, "recipient_archived": false, "real_time_user": null}}]
2011-04-30 12:16:35.838 MyApp[8097:1b03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'
*** Call stack at first throw:
(
0   CoreFoundation                      0x012b9be9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x0140e5c2 objc_exception_throw + 47
2   CoreFoundation                      0x012b37f1 -[__NSArrayM insertObject:atIndex:] + 225
3   CoreFoundation                      0x012aec44 -[__NSArrayM addObject:] + 68
4   MyApp                               0x0000e517 +[NSObject(JSONSerializableSupport) deserializeJSON:] + 354
5   MyApp                               0x0000db5e +[NSObject(JSONSerializableSupport) fromJSONData:] + 161
6   MyApp                               0x0001176b +[NSObject(ObjectiveResource) findAllRemoteWithResponse:] + 327
7   MyApp                               0x000055c8 __-[ConversationsLoader loadConversations]_block_invoke_1 + 137
8   libSystem.B.dylib                   0x97266fc4 _dispatch_call_block_and_release + 16
9   libSystem.B.dylib                   0x97259292 _dispatch_worker_thread2 + 228
10  libSystem.B.dylib                   0x97258d21 _pthread_wqthread + 390
11  libSystem.B.dylib                   0x97258b66 start_wqthread + 30
)
terminate called after throwing an instance of 'NSException'

I either need a way to work around the namespace conflict issue with 1.01, or I need a way to avoid this crash on 1.1. Can anyone point me in the right direction on this?

Aaron Russell

unread,
May 2, 2011, 12:29:17 PM5/2/11
to objectiv...@googlegroups.com
Ended up going back to ObjectiveResource 1.01 and deliberately misspelling my Rails class and adding some stuff to the routes to handle the misspelt name in the URL and some filters to the JSON output to make it match the mis-spelt name the iPhone app is using. A bit of a hack I guess, but it works.

Aaron Russell

unread,
May 2, 2011, 12:30:22 PM5/2/11
to objectiv...@googlegroups.com
"...deliberately misspelling my ObjectiveResource class", that should've said.
Reply all
Reply to author
Forward
0 new messages