草庐IT

Unwrapping

全部标签

ios - 展开可选值时意外发现 nil

这个问题在这里已经有了答案:Whatdoes"Fatalerror:UnexpectedlyfoundnilwhileunwrappinganOptionalvalue"mean?(16个答案)关闭3年前。在我的应用程序中,我正在检查帖子是否有图片。为此,我正在使用:ifpictures[string]?!=nil{ifvarimage:NSData?=pictures[string]?{imageView.image=UIImage(data:image!)}}但是还是报错:fatalerror:unexpectedlyfoundnilwhileunwrappinganOptiona

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

这个问题在这里已经有了答案:Whatdoes"Fatalerror:UnexpectedlyfoundnilwhileunwrappinganOptionalvalue"mean?(16个答案)关闭1年前。我正在尝试运行此代码,但我一直收到此错误:fatalerror:unexpectedlyfoundnilwhileunwrappinganOptionalvalue我不明白这是什么意思,也不明白为什么我会得到它。有什么提示吗?importUIKitclassViewController:UIViewController{varlastNumber:String=""@IBOutlet

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

这个问题在这里已经有了答案:Whatdoes"Fatalerror:UnexpectedlyfoundnilwhileunwrappinganOptionalvalue"mean?(16个答案)关闭1年前。我正在尝试运行此代码,但我一直收到此错误:fatalerror:unexpectedlyfoundnilwhileunwrappinganOptionalvalue我不明白这是什么意思,也不明白为什么我会得到它。有什么提示吗?importUIKitclassViewController:UIViewController{varlastNumber:String=""@IBOutlet

swift - fatal error : unexpectedly found nil while unwrapping an Optional value - using UITableView

我在ViewController中使用UITableView。在viewDidLoad中我有这个:varPlayersUserDefault=NSUserDefaults.standardUserDefaults()if(PlayersUserDefault.arrayForKey("playersKey")!=nil){players=PlayersUserDefault.arrayForKey("playersKey")}这段代码给我错误:functableView(tableView:UITableView,numberOfRowsInSectionsection:Int)->I

ios - 线程 1 : Fatal error: Unexpectedly found nil while unwrapping an Optional value while applying effects to image

我正在尝试对ImageView应用滑动、淡入淡出和增长效果。以下是我的代码@IBActionfuncfadeIn(_sender:Any){imageView.alpha=0UIView.animate(withDuration:1,animations:{self.imageView.alpha=1})}@IBActionfuncslideIn(_sender:Any){imageView.center=CGPoint(x:imageView.center.x-500,y:imageView.center.y)UIView.animate(withDuration:2){self.i

ios - 从 NSData 创建 UIImage 时出现 "fatal error: unexpectedly found nil while unwrapping an Optional value"

首先,我将一张图片转换为NSData,并借助fmdb(飞肉数据库)以sqliteblob的形式插入到sqlite数据库中。然后我取回NSData,但是在将NSData转换为UIImage时出现错误“fatalerror:在展开可选值时意外发现nil”。varimageData=String()letcountryDB=FMDatabase(path:databasePathasString)ifcountryDB.open(){letquerySQL="SELECTUSERIMAGEFROMUSERINFOWHEREID=\((1))"letresults:FMResultSet?=c

ios - 为什么 UILabel.text 会导致 “fatal error: unexpectedly found nil while unwrapping an Optional value” ?

我已经阅读了这个问题的几个答案,并尝试了所有建议但没有成功。我是swift的新手,正在使用Swift、PHP和MySQL构建应用程序。我在用户登录到应用程序后收到错误消息,系统应该使用UILabel.text通过标签显示用户名。为UILabel.text变量设置值时发生错误。我的代码包含在下面。我尝试在其他页面上对值进行硬编码,但在我的整个项目中都遇到了这个错误。importUIKitclassHomeViewController:UITabBarController{@IBOutletvarusernameLbl:UILabel!overridefuncviewDidLoad(){s

uitableview - swift - 错误 : unexpectedly found nil while unwrapping an optional value

我一直在用Swift制作应用程序,但我的TableViewController类中一直出现错误。我找不到任何方法来解决此问题并不断收到此错误:overridefunctableView(tableView:UITableView?,cellForRowAtIndexPathindexPath:NSIndexPath!)->UITableViewCell!{letcell:TextTableViewCell=tableView!.dequeueReusableCellWithIdentifier("Cell",forIndexPath:indexPath!)asTextTableView

swift - 从 Parse.com 检索 PFFile 时为 "unexpectedly found nil while unwrapping an Optional value"

我在检索存储在Parse.com中的PFFile时遇到问题letuser=PFUser.currentUser()letuserImageFile=user["profileImage"]asPFFileuserImageFile.getDataInBackgroundWithBlock{(imageData:NSData!,error:NSError!)->Voidiniferror==nil{ifimageData!=nil{letimage=UIImage(data:imageData)self.profileImage.image=image}}}错误从第二行开始。“profi

ios - 在 Swift ios 中使用 vImageBuffer_initWithCGImage 时出现 "fatal error: unexpectedly found nil while unwrapping an Optional value"

我正在使用SwiftiOS8并尝试将UIImage转换为vImage_Buffer以使用Accelerate.framework执行操作。我正在尝试使用vImageBuffer_initWithCGImage进行转换,这是我尝试过的代码:funcinitvImageBufferwithUIImage(image:UIImage)->vImage_Buffer{varCGImg:CGImageRef=sunset.CGImagevarinProvider:CGDataProviderRef=CGImageGetDataProvider(CGImg)varinBitmapData:CFDa