0

I have seen this question somewhat answered here but in my case I am using NSURLSession to display images. These images are uploaded by user or scanned into a database using a script.

In this case writing exception URL's (NSExceptionDomains) won't work because the image is hosted by a user on their site or some other site. If I allow NSAllowsArbitraryLoads will I still be able to be approve for App Store since I am not implementing the best practices of ATS?

I am not sure the best way to proceed. Any input would be appreciated!

Here is the code I am using.

    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];
4

1 回答 1

0

是的,即使使用此参数,您也会通过 Review。自 iOS9 SDK 以来,我们已经上传了许多构建,并NSAllowsArbitraryLoads设置为YES.

PS:您的代码最好如下所示:

cell.thumbnailURL = URL;
__weak typeof(cell) weak
NSURLSessionDownloadTask *downloadPhotoTask = [session downloadTaskWithURL:URL completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
    NSData *imageData = [[NSData alloc] initWithContentsOfURL:location];
    UIImage *image = [UIImage imageWithData:imageData];
    dispatch_async(dispatch_get_main_queue(), ^{
        if (weakCell.thumbnailURL != URL) {
            return;
        }
        weakCell.tableImageView.image = image;
    });
}];
[downloadPhotoTask resume];
于 2015-12-01T12:47:36.407 回答