0

在测试(在真实设备上) AVAssetDownloadURLSession 时,我注意到当我将斜杠“/”放入assetTitle 时,我收到错误:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could 
not be completed" UserInfo={NSLocalizedDescription=The operation could 
not be completed, NSLocalizedFailureReason=An unknown error occurred 
(-12780)}

示例代码:

AVAssetDownloadTask * assetDownloadTask = [urlSession 
assetDownloadTaskWithURLAsset:urlAsset assetTitle:@"One two three 
(open/close)" assetArtworkData:nil options:nil];

来自 Apple 的文档(https://developer.apple.com/documentation/avfoundation/avassetdownloadurlsession/1650938-assetdownloadtaskwithurlasset):

title
A human readable title for this asset in the user's preferred language. 
This value will be displayed in the usage pane of the Settings app.

我认为上面的例子是人类可读的。我是否需要将斜杠视为特殊字符并以某种方式对其进行转义以正确分配它?

4

1 回答 1

0

是的,目前我需要在我的头衔上这样做:

 NSCharacterSet *setToRemove = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "];
 NSCharacterSet *setToKeep = [setToRemove invertedSet];
 NSString *downloadTitle = [[[item getTitle] componentsSeparatedByCharactersInSet:setToKeep] componentsJoinedByString:@""];
于 2017-11-13T08:54:54.887 回答