草庐IT

swift - "Cannot call value of non-function type"

我刚刚下载了Xcode8Beta,以便可以在我的应用程序中包含一些新的iOS10框架。然而,在将我的代码从Swift2转换为Swift3的过程中,我遇到了几个错误。除了一个super烦人的,我都修好了。我收到错误:Cannotcallvalueofnon-functiontype'JSQMessagesCollectionView!'atthefollowinglineofcode:letcell=super.collectionView(collectionView,cellForItemAtIndexPath:indexPath)as!JSQMessagesCollectionVi

iphone - 为什么在将 Float 转换为 CGFloat 时 Xcode 给我一个警告 "Cannot convert value of type ' CGFloat' to expected argument type 'UnsafeMutablePointer"?

我正在尝试将Float值转换为CGFloat值,这里是我的代码:letmyFloatForR=0letr=CGFloat(myFloatForR)letmyFloatForG=0letg=CGFloat(myFloatForG)letmyFloatForB=0letb=CGFloat(myFloatForB)letmyFloatForA=0leta=CGFloat(myFloatForA)tintColor.getRed(r,green:&g,blue:&b,alpha:&a)但Xcode突然给我一个警告说:“无法将类型'CGFloat'的值转换为“tintColor”行上的预期参数类

ios - Swift 中的 NSDictionary :Cannot subscript a value of type 'AnyObject?' with a index of type 'Int'

所以我正在尝试使用swift解析JSON中的一些数据。下面是我的代码varjsonResult:NSDictionary!=NSJSONSerialization.JSONObjectWithData(data,options:NSJSONReadingOptions.MutableContainers,error:nil)as!NSDictionaryprintln(jsonResult)上面的代码会返回这样的东西{count=100subjects=({alt="....."name="....."},{alt="....."name="....."},......)}然后我尝试使

swift - 在 OSX : class is not key value coding-compliant for the key {name of binding var} 中绑定(bind)

我试图按照B.A.LearningSwift书(创建笔记应用程序)中的说明进行操作。Paris&Co,但面临以下绑定(bind)问题。我主要练习iOS编程,所以绑定(bind)概念对我来说是新的。我执行的步骤(尝试了xcode9beta5和8.3.3):创建OSXCocoa应用程序(不使用Storyboard,基于文档的应用程序,文档扩展名“测试”,不要使用核心数据)将“vartext=NSAttributedString()”添加到Document.swift将NSTextView添加到Document.xib在NSTextView的绑定(bind)检查器中,将“属性字符串”设置为文

swift - 如何修复 'can not use mutating member on immutable value' ?

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭5年前。Improvethisquestion获取错误:Error:cannotusemutatingmemberonimmutablevalue:'fromArray'isa'let'constant在下面的代码中:funcremoving(item:Int,fromArray:[Int])->[

swift 字典 : join key and value into string

我正在为此寻找最佳语法:letresponseParameters=["keyA":"valueA","keyB":"valueB"]varresponseString=""for(key,value)inresponseParameters{responseString+="\(key):\(value)"ifArray(responseParameters.keys).last!=key{responseString+="+"}}//responseString:keyA:valueA+keyB:valueB类似于数组joinWithSeparator,使用flatMap或类似的东

swift - 按字母顺序排序字典无法将类型 '[(key: String, value: AnyObject)]' 的值分配给类型 'Dictionary<String, AnyObject>?'

我有这个字典,它是我从网络服务中获取的:letjson=tryJSONSerialization.jsonObject(with:data!,options:.allowFragments)as!Dictionary现在我正尝试按字母顺序对它们进行排序:self.appDelegate.communityArray=json.sorted(by:{$0.0但是我得到这个错误:Cannotassignvalueoftype'[(key:String,value:AnyObject)]'totype'Dictionary?'我做错了什么?这就是我定义communityArray的方式:va

ios - Swift 可解码 : how to transform one of values during decoding?

默认情况下,Decodable协议(protocol)将JSON值转换为对象值而无需更改。但有时你需要在json解码期间转换值,例如,在JSON中你得到{id="id10"}但在你的类实例中你需要输入数字10进入属性id(或者甚至进入具有不同名称的属性)。您可以实现方法init(from:),您可以在其中使用任何值执行您想要的操作,例如:publicrequiredinit(fromdecoder:Decoder)throws{letcontainer=trydecoder.container(keyedBy:CodingKeys.self)latitude=trycontainer.

ios - swift JSON 错误 : Could not cast value of type '__NSDictionaryM' to 'NSArray'

从web服务(API)解码JSON时出现错误:Couldnotcastvalueoftype'__NSDictionaryM'(0x1037ad8a8)to'NSArray'(0x1037ad470).我的代码:varkGetURL="http://bitnami.local/cscart_demo/api/users"//varkGetURL="http://localhost/fendy/getjson.php"varjson:Array=[]overridefuncviewDidLoad(){super.viewDidLoad()start()}funcgetData(data:

swift 2 : Value of type 'Set<UITouch>' has no member 'anyObject'

这个问题在这里已经有了答案:Overridingmethodwithselector'touchesBegan:withEvent:'hasincompatibletype'(NSSet,UIEvent)->()'(9个回答)关闭6年前。我检查了我的旧游戏,我想在Swift2.0中更新它。当我试图修复它时,Xcode发现了一个错误。错误是Valueoftype'Set'hasnomember'anyObject'在这行代码中:vartouch:UITouch=touches.anyObject()as!UITouch功能:overridefunctouchesEnded(touches