草庐IT

glx_context

全部标签

ios - 如何解决 "Type of expression in ambiguous without more context"?

letattributedString=NSAttributedString(data:encodedData,options:attributedOptions,documentAttributes:nil,error:nil)!编译器错误:“表达式类型不明确,没有更多上下文”怎么解决的? 最佳答案 要求[String:AnyObject]attributedOptions参数要求的格式do{letencodedData=yourEncodedString.dataUsingEncoding(NSUTF8StringEncodin

swift - "Type of expression is ambiguous without more context"尝试创建新变量以附加数组时

我是编码和Swift的新手,现在正在尝试创建一个小型应用程序。我创建了这部分代码:overridefunctableView(tableView:UITableView,didSelectRowAtIndexPathindexPath:NSIndexPath){tableView.deselectRowAtIndexPath(indexPath,animated:true)letcell=tableView.cellForRowAtIndexPath(indexPath)varselectedSubject=toBeAddedSubjects[indexPath.row]asSubje

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 - 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

swift - iOS 12 错误 : appears to be from a different NSManagedObjectModel than this context's

在iOS12模拟器上启动我的应用程序时,我开始遇到以下错误。有人遇到过这样的问题吗?2018-08-1121:17:44.440144+0300CafeManager[4633:128874][error]error:Thefetchrequest'sentity0x600001f6e940'TablesTable'appearstobefromadifferentNSManagedObjectModelthanthiscontext's我在AppDelegate中定义了全局常量:letviewContext=AppDelegate.viewContext并将其与NSFetchedRe