Question

I have an iOS app which gets some JSON from a server (in the form of NSData). I use the SBJson framework's parser to convert that to an NSDictionary object, like so:

SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *content = [parser objectWithData:data];

I then proceed to read objects from 'content' etc.

Now, this exact code has worked PERFECT using an old version of the SBJson framework. The program was fine. Then I implemented a new version of the SBJson framework and all of a sudden my program crashes when I try to do the same things with 'content' (To be more specific I get an EXC_BAD_ACCESS error).

My first thought was that the new SBJsonParser produced a slightly different file, and so I logged both the new and the old 'content' to text files and ran the 'diff' command on them from the command line. They are EXACTLY the same.

So, the ONLY change I made was to use the new SBJsonParser. What am I missing?

Was it helpful?

Solution

The solution was to change my code slightly:

SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *content = [[parser objectWithData:data] retain];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top