sas*_*nec 12 ios nsurlerrordomain nsurlsession
我尝试NSURLSession在iOS 8中使用共享扩展程序上传图像,但在调用后立即出现此错误
[task resume]
Error Domain=NSURLErrorDomain Code=-995 "The operation couldn’t be completed. (NSURLErrorDomain error -995.)"
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:DEFAULT_SHARE_SESSION_ID];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:self.queue];
NSURLRequest *request = [self getMultipartUploadRequest:data url:url albumId:albumId];
// ... saving file here to Documents folder
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request fromFile:url1];
[uploadTask resume];
Run Code Online (Sandbox Code Playgroud)
而且我在控制台中也有这条消息:
Attempted to create a task in a session that has been invalidated
Run Code Online (Sandbox Code Playgroud)
此代码绝对适用于应用程序,但在共享扩展程序中不起作用.我找不到代码-995的含义.
有任何想法吗?
sas*_*nec 14
@Wisors很棒!它有所帮助,只需要设置
sessionConfiguration.sharedContainerIdentifier = @“com.me.myapp.containerIdentifier”;
Run Code Online (Sandbox Code Playgroud)
在我的情况下@"com.me.myapp.containerIdentifier"是@"group.mycompany.appname"这是至关重要的,另一个标识符不起作用.谢谢!
| 归档时间: |
|
| 查看次数: |
4824 次 |
| 最近记录: |