0
IAM正从Web服务的数据,但它是在URL请求坠毁看到下面的代码应用程序崩溃的原因异常NSInvalidArgumentException
- (void)loadDataSource
{
// Request
NSString *URLPath = [NSString stringWithFormat:@"http://imgur.com/gallery.json"];
NSURL *URL = [NSURL URLWithString:URLPath];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
**CRASHED HERE** [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSInteger responseCode = [(NSHTTPURLResponse *)response statusCode];
if (!error && responseCode == 200) {
id res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
if (res && [res isKindOfClass:[NSDictionary class]]) {
self.items = [res objectForKey:@"gallery"];
[self dataSourceDidLoad];
} else {
[self dataSourceDidError];
}
} else {
[self dataSourceDidError];
}
}];
}
请帮我提前
好的我现在会改变 – kishore
非常感谢你 – kishore