草庐IT

col_value

全部标签

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

IOS FoodTracker 教程 : Value of tuple type '()' has no member 'path'

我正在完成IOSSwift教程“FoodTracker”,但是有一个错误我可以找到解决方案,但我不明白哪里出了问题以及如何解决它:错误:Valueoftupletype'()'hasnomember'path'此错误在以下代码中针对变量“Meal.ArchiveUrl.path”显示。我的代码,在MealtableViewController(相当于IOS教程):privatefuncsaveMeals(){letisSuccessfulSave=NSKeyedArchiver.archiveRootObject(meals,toFile:Meal.ArchiveUrl.path)if

ios - Obj-C 框架返回 nil,并使我的 Swift 代码崩溃并显示 'fatal error: unexpectedly found nil while unwrapping an Optional value'

我正在使用用Obj-C编写的第三方框架,它有一个功能:-(NSError*)generateModelForm如果此方法成功,它将返回nil。如果它不返回nil,它将返回一个错误,您可以检查该错误以进行调试。现在,当我使用桥接头在我的Swift文件中调用此函数并执行所有必需的操作时,它总是在第一行崩溃并显示“fatalerror:在展开可选值时意外发现nil”我的Swift代码:ifleterror=object.generateModelForm(){println("Error:\(error)")}else{println("Successfullygeneratedmodelf