I was using the SBJSON files from this JSON tutorial and开发者_运维技巧 then I tried using the Facebook iOS SDK. The Facebook SDK happens to have the same SBJSON files.. but apparently is a lot different. I cannot use both folder groups because I get "duplication errors" in Xcode. I tried removing the original JSON folder group, and now I get the following warnings: SBJsonParser may not respond to objectWithString:error:
and a SIGABRT
crash at this line: return [jsonParser objectWithString:jsonString error:NULL];
Anyone know how I can fix this? Thanks in advance!
// JSON from Server Actions
- (NSString *)stringWithUrl:(NSURL *)url {
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadRevalidatingCacheData
timeoutInterval:30];
// Fetch the JSON response
NSData *urlData;
NSURLResponse *response;
NSError *error;
// Make synchronous request
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
// Construct a String around the Data from the response
return [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
}
- (id)objectWithUrl:(NSURL *)url {
SBJsonParser *jsonParser = [SBJsonParser new];
NSString *jsonString = [self stringWithUrl:url];
// Parse the JSON into an Object
return [jsonParser objectWithString:jsonString error:NULL];
}
- (NSDictionary *)downloadManifest {
id response = [self objectWithUrl:[NSURL URLWithString:@"http://example.com/manifest.json"]];
NSDictionary *feed = (NSDictionary *)response;
return feed;
}
https://nodeload.github.com/gabriel/yajl-objc/zipball/master
try with this parser...
精彩评论