Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBJson iOS parser methods are Deprecated?

Tags:

json

ios

sbjson

I'm starting a new project with SBJson parser, which people seem to recommend as the best on the internet for new iOS projects. I'm having a really strage issue which is that the current methods Stig Brautaset claims you can use on the current release (3.1), seem to be deprecated, or at least thats what my compiler is saying. I cant seem to get either to work:

NSDictionary *dict = [responseString JSONValue];

Which seems to be the most current way to do this or:

NSDictionary *dict = [parser objectWithString:responseString error:&error];

Where parser is a sbjson parser. XCode highlights both of these functions and tells me they are deprecated.

What am I doing wrong here??

like image 792
Jameo Avatar asked Jan 03 '13 16:01

Jameo


1 Answers

Looking at the source code here and here it looks that both

- (id)objectWithString:(NSString*)jsonText error:(NSError**)error

and

- (id)JSONValue;

are deprecated since version 3.2 and it will be removed in version 4.0. Are you sure you are using the 3.1?

On the other hand both

- (id)objectWithString:(NSString *)repr;

and

- (id)objectWithData:(NSData*)data;

look available and not deprecated.

I would suggest you to use them instead.

An alternative is to use the NSJSONSerialization class provided by Apple.

like image 130
Gabriele Petronella Avatar answered Nov 15 '22 12:11

Gabriele Petronella