No visible @interface for 'SBJson4Parser' declares the selector 'objectWithString:error'

1.2k Views Asked by At

I've founded this error "no visible @interface for 'SBJson4Parser' declares the selector 'objectWithString:error'" when I've done importing "SBJson4.h" in my code. I don't know why I've founed this error.

SBJson4Parser *parser = [[SBJson4Parser alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@""]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSArray *statuses = [parser objectWithString:json_string error:nil];
for (NSDictionary *status in statuses) {
    NSLog(@"%@ - %@", [status objectForKey:@"Name"], [status objectForKey:@"LoginUrl"] );
}
1

There are 1 best solutions below

2
Stig Brautaset On

The interface completely changed in version 4. You need to read the docs when you upgrade major versions! That method doesn't exist in version 4. Stick with version 3.2.x if you want that, or upgrade to NSJSONSerialisation if you don't need streaming support.