我使用的是来自this JSON tutorial的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;
}