草庐IT

multi-value-dictionary

全部标签

ios - 错误 : Cannot subscript a value of type 'inout [Agenda]' (aka 'inout Array<Agenda>' )

我正在制作一个应用程序,当您按下一个表示紧急的按钮时,会有一个标签显示“紧急”。就在我实现与按钮的用户交互之前,我有一个数组(如下所示),其中一些对象具有urgent=true,但有些对象具有urgent=false,所以我可以从我的代码开始。MainTableViewController.swift中的数组:varcontent:[Agenda]=[Agenda(subject:"Readthisarticle",deadline:"1-2days",urgent:false),Agenda(subject:"Respondtothisemail",deadline:"ASAP",u

macos - swift 错误 : Cannot assign to immutable value

此代码段出现上述错误:funcstore(name:String,inoutarray:[AnyObject]){forobjectinarray{ifobjectis[AnyObject]{store(name,&object)return}}array.append(name)}有什么想法吗? 最佳答案 用for提取的项目object是不可变的。您应该改为迭代数组的indices。并且,该项目是AnyObject,您不能在不强制转换的情况下将其传递给inoutarray:[AnyObject]参数。在这种情况下,您应该将其转换为

ios - Swift 在 Optional() 中获取值(value)

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭6年前。Improvethisquestion当我从我正在访问的API中获取返回值时,当我打印数据时,它显示为Optional((jknjknjkn))例如。我使用选择器在返回数据时运行方法funcresult(data:AnyObject){println(data["info"])}打印出来的就是上面的Optional的东西。如果没有Opt

ios - swift 错误 : Value of type 'NSObject -> () ' AnimalListTableViewController' has no member 'tableView'

我正试图在swiftxcode中消除这些错误如果截图太小,这里是代码importUIKitclassAnimalListTableViewController:UITableViewController{overridefunctableView(tableView:UITableView,numberOfRowsInSectionsection:Int)->Int{return4}letindexPath=self.tableView.indexPathForSelectedRow()//thisiswheretheerrorappears,itsaysValueoftype'NSO

swift 2 : Cannot convert value of type '[NSObject : AnyObject]' to expected argument type '[String : AnyObject]'

我有一个用Swift1构建的项目。但是在自动转换为Swift2后,它显示错误:无法将类型'[NSObject:AnyObject]'的值转换为预期的参数类型'[String:AnyObject]'。函数代码:funccreateViewContainers()->NSDictionary{varcontainersDict=NSMutableDictionary()letitemsCount:Int=tabBar.items!.countasInt-1forindexin0...itemsCount{varviewContainer=createViewContainer()conta

ios - swift 错误 : Could not cast value of type 'NSTaggedPointerString' (0x1a1264378) to 'NSNumber' (0x1a126f900)

我在Xcode(swift)中遇到这个错误:Couldnotcastvalueoftype'NSTaggedPointerString'(0x1a1264378)to'NSNumber'(0x1a126f900).我用//ERROR:("...")明确了错误在哪里代码:importUIKitimportiAdimportAVFoundationimportAudioToolboxletMAX:UInt32=4letMIN:UInt32=1classViewController:UIViewController,ADBannerViewDelegate{varchances=10varw

swift - 错误 : cannot convert value of type '() -> ()' to closure result type 'String' using Swift + PromiseKit

我不熟悉Swift中的promise,并使用PromiseKit尝试在Playground上创建一个非常简单的响应并尝试使用它。我有以下代码:importUIKitimportPromiseKitfuncfoo(_error:Bool)->Promise{returnPromise{fulfill,rejectinif(!error){fulfill("foo")}else{reject(Error(domain:"",code:1,userInfo:nil))}}}foo(true).then{response->Stringin{print(response)}}但是我得到以下错误

ios - 无法将类型 'Dictionary<String?, String?>.Keys' 的值分配给类型 'String'

这里我有一个数据库,我想轻松地将其用于我的TableView。但是,我无法访问属性,因为我不知道如何从字典分配给字符串。它告诉我:Cannotassignvalueoftype'Dictionary.Keys'totype'String'importFoundationstructTest{vartitle:StringvartagPreview:Tagpreview}structTagpreview{vartag:[String?:String?]}varcases=[Test(title:"title1",tagPreview:Tagpreview(tag:["tag1":"pre

swift - 如何在 Swift 2 中将 Array<String> 添加到 Dictionary<String, AnyObject>

已解决!请参阅本文底部的解决方案我正在尝试使用Alamofire创建一个JSON对象以用于我的后端。我可以添加一个带有字符串值的键,但似乎无法将数组值添加到AnyObject。我虽然这会非常简单,但我一直无法找到解决方案。funcsomeFunction(btn:UIButton){varsomeDictionary=Dictionary()letsomeArray=[textField[1].text,textField[2].text,textField[3].text]someDictionary["answer"]=textField[0].textsomeDictionary

ios - alamofire post 方法中的 response.result.value 为 nil

letparametersDictionary=["email":"name@gmail.com","password":"password"]Alamofire.request("http://nanosoftech.com/store/user_check",method:.post,parameters:(parametersDictionaryasNSDictionary)as?Parameters,encoding:JSONEncoding.default,headers:nil).responseJSON{responseinprint("response:",respon