帮助 SBJSON + Facebook SDK 冲突
我正在使用 这个 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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://nodeload.github.com/gabriel/yajl-objc/zipball/master
尝试使用这个解析器...
https://nodeload.github.com/gabriel/yajl-objc/zipball/master
try with this parser...