创建AVAssetDownloadURLSession需要com.apple.developer.media-asset-download权利

时间:2017-07-06 06:16:51

标签: objective-c nsurlsession entitlements avasset

当我尝试在iOS 9.0中构建AVAssetDownloadURLSession的实例时,它有一个例外。

原因:'创建AVAssetDownloadURLSession需要com.apple.developer.media-asset-download权利'。

我不知道如何解决这个问题。请帮帮我。

我的代码:

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"AX"];
configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
configuration.shouldUseExtendedBackgroundIdleMode = YES;
configuration.sessionSendsLaunchEvents = YES;
configuration.HTTPShouldSetCookies = YES;
configuration.HTTPShouldUsePipelining = NO;
configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
configuration.allowsCellularAccess = YES;
configuration.timeoutIntervalForRequest = 60.0;
configuration.HTTPMaximumConnectionsPerHost = 10;
configuration.discretionary = YES;

NSOperationQueue *queue = [[NSOperationQueue alloc] init];
queue.maxConcurrentOperationCount = 3;

AVAssetDownloadURLSession *session = [AVAssetDownloadURLSession sessionWithConfiguration:configuration assetDownloadDelegate:self delegateQueue:[NSOperationQueue mainQueue]];

2 个答案:

答案 0 :(得分:1)

AVDownloadURLSession仅适用于设备。如果你在模拟器上尝试它会崩溃。尝试在设备上运行此代码。它会起作用。

答案 1 :(得分:0)

@martin的答案是正确的。使用TARGET_IOS_SIMULATOR注释掉AVAssetDownloadURLSession相关代码以在模拟器上进行调试。