草庐IT

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

objective-c - fatal error : unexpectedly found nil while unwrapping an Optional value, 快速获取 json 错误

获取json错误当我尝试返回json时,出现错误fatalerror:unwrappedlyfoundnilwhileunwrappinganOptionalvalue:funcgetJson(str:NSString)->AnyObject{varproxiesURL=NSURL(string:str)varproxiesDataJson=NSData.dataWithContentsOfURL(proxiesURL,options:NSDataReadingOptions.DataReadingUncached,error:nil)varjson:AnyObject!if(prox

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

我有一个问题,因为当我尝试获取位置用户并在我的.plist中获得权限时,我的应用程序崩溃了,这是我的代码。importUIKitimportMapKitimportCoreLocationclassmapClass:UIViewController,MKMapViewDelegate,CLLocationManagerDelegate{varlocation4=CLLocation()varlm=CLLocationManager()@IBOutletvarpropMapa:MKMapView!lm.delegate=selflm.desiredAccuracy=kCLLocation

Swift 在可空性可用之前使用 Implicitly Unwrapped Optional

在Apple关于可空性的博客中,他们提到了这一点:"...inSwiftthere’sastrongdistinctionbetweenoptionalandnon-optionalreferences,e.g.NSViewvs.NSView?,whileObjective-CrepresentsbothsofthesetwotypesasNSView*.BecausetheSwiftcompilercan’tbesurewhetheraparticularNSView*isoptionalornot,thetypeisbroughtintoSwiftasanimplicitlyunw

ios - Swift 通用变量 fatal error : unexpectedly found nil while unwrapping an Optional value

我正在尝试实现一个简单的通用方法:funcfindMax(numbers_array:[T])->(min_tuple:T,max_tuple:T){varmax_number:T?varmin_number:T?foriinnumbers_array{if(max_numberi){min_number=i}}return(min_number!,max_number!)}我正在尝试访问这样的方法:letresult=findMax([3.4,5,-7,-7.8])但是每当我运行这段代码时,我都会收到以下错误:fatalerror:unexpectedlyfoundnilwhileu

swift - fatal error : unexpectedly found nil while unwrapping an Optional value when using AudioPlayer in Swift 2

您好,我正在尝试在swift2中使用以下代码播放音乐文件。基本上我只是将名为f.mp3的音频文件拖到asses文件夹中,我的代码中断并显示以下消息:在展开一个Optional值时意外地发现nil。我需要将mp3文件放在哪里,以便IOS可以找到它。谢谢varaudioPlayer:AVAudioPlayer!=nilfuncplayMyFile(){letpath=NSBundle.mainBundle().pathForResource("f",ofType:"mp3")letfileURL=NSURL(fileURLWithPath:path)do{tryaudioPlayer=AV

iOS 8 核心数据堆栈 - fatal error : found nil while unwrapping an Optional value

我是iOS开发的新手,因此决定实现我自己的核心数据堆栈,以取代Apple的默认堆栈。我不得不对我的代码进行更改(很明显)并且已经能够弄清楚,但是在这种情况下我不能。这是我的代码:importUIKitimportCoreDataclassAddTableViewController:UITableViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate{@IBOutletweakvarnameTextField:UITextField!@IBOutletweakvarlocationTex

swift - UICollectionView 问题 "fatal error: unexpectedly found nil while unwrapping an Optional value"

编辑:添加异常断点后(感谢大牛T),发现原来是我的cell.askingUsernameLabel.text=NSString(string:arr[indexPath.row])返回nil。这个问题的解决方案是在swift中,注册子类会覆盖你在Storyboard中所做的事情(如果使用Storyboard)。直接删除self.collectionView.registerClass(CollectionViewCell.self,forCellWithReuseIdentifier:"CollectionViewCell")一切顺利原创我真的迷失了这个:我试图在我的ViewContr