我使用的是这个 JSON 教程中的 SBJSON 文件,然后我尝试使用 Facebook iOS SDK。Facebook SDK 恰好有相同的 SBJSON 文件。但显然有很大不同。我不能同时使用这两个文件夹组,因为我在 Xcode 中遇到“重复错误”。我尝试删除原始 JSON 文件夹组,现在我收到以下警告:SBJsonParser may not respond to objectWithString:error:
并SIGABRT
在此行崩溃:return [jsonParser objectWithString:jsonString error:NULL];
有谁知道我该如何解决这个问题?提前致谢!
// 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;
}