当我通过按电源按钮强制我的设备进入睡眠模式时,我的后台任务通过调用didCompleteWithError带有错误的委托方法停止:
该操作无法完成.不允许操作
如何配置我的NSURLSession以便在睡眠模式下继续下载?
它甚至可能吗?如果没有,我有什么选择?我需要下载一个300Mb的文件,因此在连接较低时,应用程序将在下载结束前进入睡眠模式.
这是我的会话的创建:
static NSURLSession *backgroundSession;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
backgroundSession = [NSURLSession sessionWithConfiguration:
[NSURLSessionConfiguration backgroundSessionConfiguration:
@"com.myapp.mytask"] delegate:self.
myDelegate delegateQueue:self.myQueue];
});
NSURLSessionDownloadTask *task = [backgroundSession downloadTaskWithRequest:
self.urlRequest];
[task resume];
Run Code Online (Sandbox Code Playgroud) 我有一个 Xamarin 项目(UWP 和 iOS)在 VS2015 中构建并运行良好。该项目包含一些通用 Windows 和 iOS 项目,以及两个平台使用的许多 PCL(用于视图模型、服务和数据库访问)。
PCL 正在一一正确构建。
但是当我尝试构建主要的通用 Windows 项目时,我收到此错误:
Error APPX1101
Payload contains two or more files with the same destination path 'One.Of.My.Project.pdb'
Source files: 'My.UniversalWindows.Project.scproj'
Run Code Online (Sandbox Code Playgroud)
当我进入文件资源管理器时,我可以在 \bin 和 \obj 目录中找到 pdb 文件。
在 VS2015 中,一切都构建/运行良好。我只在 VS2017 上遇到此构建错误。
我的 UWP 项目的目标和最小版本是 Build 14393(周年版),并且我的 NuGet 包已更新(特别是 v5.3.1 中的 Microsoft.NETCore.UniversalWindowsPlatform)
pdb-files portable-class-library xamarin uwp visual-studio-2017
我是Java开发人员,我曾经将我的Java实体测试为POJO.现在,使用Obj-C,我想对从NSManagedObject继承的实体做同样的事情(我使用CoreData作为持久性).
例如,我想测试我的Customer实体:
-(void)myTest {
Customer *customer = [Customer alloc] init];
customer.name = @"toto";
GHAssertEqualStrings(customer.name, @"toto", @"");
}
Run Code Online (Sandbox Code Playgroud)
但我遇到的错误是:
NSInvalidArgumentException原因: - [Customers setName:]:发送到实例的无法识别的选择器...
所以我已经使用适当的数据库模式url加载了setUp中的所有NSManagedObjectContext.现在我实例化我的客户,它的工作原理:
Customers *customer = [NSEntityDescription
insertNewObjectForEntityForName:kDataBaseCustomerKey inManagedObjectContext:ctx];
Run Code Online (Sandbox Code Playgroud)
但这是测试'POJO'的合适方式吗?我想在没有任何模型加载的情况下测试我的Customer类,因为在这种情况下我不关心datamodel.
谢谢你的建议.
问候.