草庐IT

value_uniq

全部标签

swift 4 : Escaping closures can only capture inout parameters explicitly by value

我一直在将我的代码从Swift2迁移到Swift4。我有以下代码在Swift2中运行良好:funcfetchUserThumbnailAvatar(_task:inoutURLSessionTask?,completion:@escaping(_image:UIImage?)->()){fetchUserAvatar(Session.currentUser?.avatar?.thumbnailURLasURL???URL(string:"")!,externalUrl:URL(string:thumbnailAvatar)??URL(string:"")!,&task,completi

ios - 错误 : Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey'

这个问题在这里已经有了答案:Cannotsubscriptavalueoftype'[String:Any]'withanindexoftype'UIImagePickerController.InfoKey'(8个答案)关闭3年前。我正在尝试通过CoreML重建用于图像检测的Apple测试应用程序,但出现错误:Cannotsubscriptavalueoftype'[String:Any]'withanindexoftype'UIImagePickerController.InfoKeyextensionImageClassificationViewController:UIImag

ios - fatal error : unexpectedly found nil while unwrapping an Optional value using AVAudio

我有两个项目,使用相同的代码,但下面一行:player=AVAudioPlayer(contentsOfURL:NSURL(string:fileLocation),error:&error)仅在一个项目中返回此错误:fatalerror:unexpectedlyfoundnilunwrappinganOptionalvalue另一个项目运行没有错误。我正在尝试播放声音。importUIKitimportAVFoundationclassViewController:UIViewController{varplayer:AVAudioPlayer=AVAudioPlayer()over

swift - SceneKit—— fatal error : unexpectedly found nil while unwrapping an Optional value when getting child node

所以我试图在我的SceneKit/Swift项目中使用3D对象(.dae1.4,使用Cinema4Dr13导出)。我留下了提供的代码并进行了更改:letscene=SCNScene(named:"art.scnassets/ship.dae")!适合我的:letscene=SCNScene(named:"art.scnassets/pyramid.dae")!我确实也将文件导入到它应该位于的项目中(在art.scnassets中)。我可以像默认飞船一样预览文件,所以这应该是正确的。我也改了:letship=scene.rootNode.childNodeWithName("ship",

ios - Swift 中的 UIPickerView 子类 : error optional value in viewForRow

我想继承UIPickerView以创建自定义DatePicker。我试过了,但是Swift中有一个错误说:unexpectedlyfoundnilwhileunwrappinganOptionalvalue在这一行:(view.viewWithTag(1)asUILabel).text=array[row]代码如下:classMyPickerView:UIPickerView,UIPickerViewDataSource,UIPickerViewDelegate{letarray=["one","two","three"]requiredinit(coderaDecoder:NSCod

ios - Swift:比较隐式展开的可选结果为 "unexpectedly found nil while unwrapping an Optional values"

如果得到这个类并且想根据值比较它的实例classLocationOption:NSObject{varname:String!varradius:Int!varvalue:String!overridefuncisEqual(object:AnyObject?)->Bool{ifletotherOption=objectas?LocationOption{return(self.name==otherOption.name)&&(self.radius==otherOption.radius)&&(self.value==otherOption.value)}returnfalse}}

ios - Xcode 错误 "value of type ' [UIViewController ]' has no member ' firstObject'”

我正在尝试创建thisGitHubrepository的Swift版本.我首先将所有代码从Objective-C直接转移到Swift,这导致了很多错误(321行文件中有60个错误)。对于这一行特定的代码self.currentViewController=self.childViewControllers.firstObject我收到这个错误:Valueoftype'[UIViewController]'hasnomember'firstObject'我试过添加as!UIViewController,并在尽可能多的位置放置感叹号和问号。我从建议的帖子中尝试的所有事情都没有帮助。

swift - 错误 : Variable with getter/setter cannot have an initial value

如何修复此错误?Variablewithgetter/settercannothaveaninitialvalue这是我的代码:functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{varcell:UITableViewCell=tableview.dequeueReusableCellWithIdentifier("cell")asUITableViewCell{//Errorcell.textLabel?.text=self.items[ind

swift - 线程 10 : Fatal error: Unexpectedly found nil while unwrapping an Optional value

我正在尝试进行服务调用以获取用户详细信息,但出现此错误:线程10:fatalerror:在展开可选值时意外发现nil从这段代码:leturlString="http://myURL.com/getInfo/getAccountTransactions/{accountPublicKey}"print(urlString)letrequestUrl=URL(string:urlString)letrequestURL=URLRequest(url:requestUrl!)当我将代码包装在一个守卫中时,让代码不会被执行,因为它发现nil,我不确定为什么,因为URL字符串永远不会是nill,

ios - 打印值(value) $0

我有一行代码看起来像这样......letmyMessages=theObjects.filter{$0.myJid.user==user.JID.user}现在我想打印$0.myJid.user的值。我怎样才能做到这一点……? 最佳答案 另一种选择:letmyMessages=theObjects.filter{print($0.myJid.user);return$0.myJid.user==user.JID.user} 关于ios-打印值(value)$0,我们在StackOver