草庐IT

unwrapped

全部标签

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:比较隐式展开的可选结果为 "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}}

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,

uitableview - fetchedResultsController核心数据 fatal error : unexpectedly found nil while unwrapping an Optional value

我知道有无数的问题都出现了同样的错误,但似乎没有一个解决方案有效。我想制作一个博客阅读器应用程序,用于从CoreData保存和获取数据。我能够将JSON结果保存到CoreData中,但是当我尝试检索它以在tableView中显示时,它崩溃并显示fatalerror:unexpectedlyfoundnilwhileunwrappinganOptionalvalueonlineletentity=NSEntityDescription.entityForName("博客",inManagedObjectContext:self.managedObjectContext!)这是我的代码:i

ios - mapView.addAnnotation() 表示 "unexpectedly found nil while unwrapping an Optional value"

我尝试从tableView单元格的地址转到mapView并在map上显示图钉。我确定我的代码中的所有内容都不为零。但是Xcode说我的oldValue是nil(在didSet{}中)。我不知道如何解决它。以下是我的代码:classMapViewController:UIViewController,MKMapViewDelegate{@IBOutletweakvarmapView:MKMapView!{didSet{mapView.mapType=.StandardmapView.delegate=self}}varlocation:CLLocation?{didSet{clearWa

ios - 捕获所有 "unexpectedly found nil while unwrapping an Optional value"

我有一个大型swift项目,从JSON获取大量数据。很难检查每一个数据和平是否为零。有没有办法捕获所有这些nils,以便我的应用程序在遇到意外nils时不会崩溃?或者我必须在我拥有的所有数据中使用“ifletvariable=...”!谢谢 最佳答案 坏消息:是的,您应该始终检查可选项。好消息:有比iflet更实用的快捷方式。例如。您可以提供合理的默认值(使用“nil-coalescingoperator”)。letitemID=jsonData["itemID"]as?NSNumber??0letstringVariable=js

swift - NS编码: Found nil unwrapping an Optional value

自从更新到Swift3后,我遇到了这个众所周知的崩溃,我自己无法解决...:fatalerror:unexpectedlyfoundnilwhileunwrappinganOptionalvalue*:在线self.isDefault=aDecoder.decodeObject(forKey:"BoxUserDefault_isDefault")作为!bool为什么现在会崩溃?这是我的课classBoxUserDefault:NSObject,NSCoding{varfrendlyName:Stringvarhostname:StringvarisDefault:Boolinit(fr

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

我在将UIImage分配给UIImageView的属性图像时出错funcconnectionDidFinishLoading(connection:NSURLConnection!){varerr:NSErrorvarjsonResult:NSDictionary=NSJSONSerialization.JSONObjectWithData(data,options:NSJSONReadingOptions.MutableContainers,error:nil)asNSDictionaryprintln("\(jsonResult)")ifjsonResult.count>0{let

ios - WKInterfaceTable 和 setNumberOfRows 崩溃 "unexpectedly found nil while unwrapping an Optional value"

我正在使用WatchKit,我有一个只有一个表的简单界面,但我只用了几行代码就出错了,也许我忘记了一些非常基本的东西。我的界面:表格内的行具有标识符:和自定义类:Controller由这段代码实现:importWatchKitimportFoundationclassActiveListController:WKInterfaceController{@IBOutletweakvartableView:WKInterfaceTable!overridefuncawakeWithContext(context:AnyObject?){super.awakeWithContext(cont

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

overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject!){ifsegue.identifier=="showLocalMenuDetail"{ifletindexPath=self.tableView.indexPathForSelectedRow(){self.slideMenuController()?.closeLeft()letdestinationController=segue.destinationViewControllerasDetailViewControllerdestinatio