草庐IT

myapplication-application-context

全部标签

swift - 在后台线程中将数据同步到服务器 : multiple-contexts in core data

我有两个NSManagedObjectContext:parentContext是主上下文,childContext是PrivateQueueConcurrencyType。使用childContext,我在后台线程中将数据同步到服务器,在同步成功后,我设置了data.isSynced=true。用户可能会在同步期间更改数据。这将通过设置data.isSynced=false将数据标记为脏数据。两个线程(主线程和同步线程)同时运行,如果parentContext有data.isSynced==false并且childContext有data.isSynced==true,这里可能会发生

ios - swift 警告 : Application delegate received call to -application:performFetchWithCompletionHandler: but the completion handler was never called

我在下面的模拟器中调用这个函数来模拟后台获取。然后我在日志中收到这个警告:SwiftWarning:Applicationdelegatereceivedcallto-application:performFetchWithCompletionHandler:butthecompletionhandlerwasnevercalled.我看到其他StackIverflow回答说我只需要添加completionhandler()。我试过了,它说我需要添加一个参数,这就是我迷路的地方。funcapplication(_application:UIApplication,performFetc

ios - Alamofire 4.0.0 : [String:String] is not convertible to [String : Any] & Request is ambiguous without more context

我正在将Alamofire更新到4.0.0Beta1并将XCode8更新到Beta6。首先,我得到了[String:String]isnotconvertibleto[String:Any]错误代码letparameter=["scope":"\(scope)","client":"\(clientId)"]Alamofire.request(link,withMethod:.POST,parameters:parameter,encoding:.json).responseJSON在我更改后将[String:Any]添加到参数中,错误消失但产生了新错误:Expressiontype'

ios - 将文件转换为 Swift 3 : unable to infer closure type in the current context

我正在转换我的应用程序中的一些库代码,但我不知道如何将该文件从Swift2.3转换为Swift3importUIKitstructConstraint{varidentifier:String?varattribute:NSLayoutAttribute=.centerXvarsecondAttribute:NSLayoutAttribute=.notAnAttributevarconstant:CGFloat=0varmultiplier:CGFloat=1varrelation:NSLayoutRelation=.equal}funcattributes(attrs:NSLayou

Swift for 循环 "Expression type ' [[String : String]]' is ambiguous without more context

我正在尝试从字典数组中访问以下项目,但我遇到了两个问题(都是不同的方法)。字典数组初始化如下:vartestingArray=[[String:String]()]testingArray.append(["name":"Ethiopia","url":"localhost:8088"])testingArray.append(["name":"Bugatti","url":"localhost:8088"])testingArray.append(["name":"Brazil","url":"localhost:8088"])testingArray.append(["name":

ios - Swift 中的 "func observeValueForKeyPath(keyPath : NSString, object : AnyObject, change : NSDictionary, context : Void)"问题

我已经为这样的AVPlayer添加了一个观察者self.audioPlayer.addObserver(self,forKeyPath:"currentItem.status",options:[NSKeyValueObservingOptions.New,NSKeyValueObservingOptions.Initial],context:nil)然后打电话funcobserveValueForKeyPath(keyPath:NSString,object:AnyObject,change:NSDictionary,context:Void){ifobjectas!AVPlayer

ios - 在 iOS 中使用 Core Graphics Context 绘制圆 - Objective-C 或 Swift

我是这样画一个圆的:CGContextRefcontextRef=UIGraphicsGetCurrentContext();CGContextSetLineWidth(contextRef,2.0);//CGContextSetRGBFillColor(contextRef,0,0,1.0,1.0);//CGContextSetRGBStrokeColor(contextRef,0,0,1.0,1.0);CGContextSetStrokeColorWithColor(contextRef,[colorCGColor]);CGRectcirclePoint=(CGRectMake(c

ios - swift 中 AppDelegate 和 Context 的作用是什么?

我刚刚开始使用swift在iOS应用程序开发中处理核心数据。我遇到的前两件事是:1.AppDelegate2.NSManagedObjectContext。我知道“AppDelegate.swift”文件是一个源文件,就像“ViewController.swift”一样。但在所有教程中,它都被称为“稍后将使用的东西”。或许,现在是熟悉它的时候了。你能告诉我它到底是做什么的吗?“NSManagedObjectContext”类型的对象有什么作用?它的作用是什么?能不能简单说一下它的作用?提前致谢。 最佳答案 请查看下图以直观地理解iO

xcode - 类在/Users/... 和/Applications/... 中实现。使用两个填充之一。哪个是未定义的

我知道这是使用单元测试时的常见错误消息,但我没有这样做。这是我的做法:我创建了一个新的命令行工具项目我在print("Hello,World!")行放置了一个断点我在控制台中输入类似po3+3的内容然后我收到这条消息:objc[929]:Class_TtCs18_EmptyArrayStorageisimplementedinboth/Users/tim/Library/Developer/Xcode/DerivedData/TestProject-hlekdhnmnvllzganostmsaamwjje/Build/Products/Debug/TestProjectand/Appl

ios - 错误——Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1

我正在使用自定义键盘,如果我在类里面包含这段代码,我会收到错误消息:letisPad=UIDevice.currentDevice().userInterfaceIdiom==UIUserInterfaceIdiom.PadError-Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftcfailedwithexitcode1我需要这段代码,因为当用户在iPad上运行iPhone应用程序(如instagram)时,我需要加载iPhone键盘预