【发布时间】:2016-03-05 09:31:34
【问题描述】:
我已经看到这个问题在某种程度上回答了here,但在我的情况下,我使用 NSURLSession 来显示图像。这些图像由用户上传或使用脚本扫描到数据库中。
在这种情况下,编写异常 URL (NSExceptionDomains) 将不起作用,因为图像是由用户在其网站或其他网站上托管的。如果我允许 NSAllowsArbitraryLoads,由于我没有实施 ATS 的最佳实践,我仍然能够获得 App Store 的批准吗?
我不确定最好的方法。任何意见将不胜感激!
这是我正在使用的代码。
NSString *thumbnail_url = [tempObject objectForKey:@"image"];
NSURL *url = [NSURL URLWithString:thumbnail_url];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDownloadTask *downloadPhotoTask = [session downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
NSData *imageData = [[NSData alloc] initWithContentsOfURL:location];
dispatch_async(dispatch_get_main_queue(), ^{
cell.tableImageView.image = [UIImage imageWithData:imageData];
});
}];
[downloadPhotoTask resume];
【问题讨论】:
-
NSAllowsArbitraryLoads完全是supported by Apple,因此是的,您可以使用它提交您的应用到 AppStore。
标签: ios objective-c app-transport-security