草庐IT

Nil-Coalescing

全部标签

ios - 获取 MPMoviePlayerController 的 MPMoviePlayerPlaybackDidFinishReasonUserInfoKey nil

我在我的应用程序中使用了MPMoviePlayerController。我正在尝试获取MPMoviePlayerController的完成按钮事件。但是我在[MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]中得到的值为nil,因此应用程序崩溃了。这是我的代码://DefinenotificationinclassletnotificationName=Notification.Name("moviePlayerDoneButtonClicked")//---registerandpostednotificationinviewDidLoa

ios - UICollectionViewCell 复选标记返回 nil

我试着关注this但是当我执行cell.checkmarkView.checked=true时,它返回nil,所以一切都崩溃了。这是我的MyCollectionViewCell:classMyCollectionViewCell:UICollectionViewCell{@IBOutletweakvarmyLabel:UILabel!varcheckmarkView:SSCheckMark!overrideinit(frame:CGRect){super.init(frame:frame)checkmarkView=SSCheckMark(frame:CGRect(x:frame.wi

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

我创建了一个CustomTopTabbarController来自定义标签栏。@objcMemberspublicclassCustomTopTabbarController:UITabBarController{@IBOutletweakvarcustomBar:UITabBar!publicoverridefuncviewDidLoad(){super.viewDidLoad()customBar.frame=CGRect(x:0,y:0,width:customBar.frame.size.width,height:customBar.frame.size.height)}pub

ios - 在没有 segue 的 2x ViewController 之间传递信息时,Delegate 始终为 nil

我是Xcode/Swift编程的新手,我遇到了一个小问题。我想使用委托(delegate)将信息从一个ViewController发送到第二个ViewController,而不使用segue。我阅读了很多相关内容,发现最常见的解决方案是在ViewDidLoad中使用“instance”.delegate=self,但它对我不起作用。--应用的定义--这很容易。在第一个ViewController上,我有一个按钮和一个标签。该按钮打开第二个ViewController,它有一个textField和一个Button。Button将textField中的内容发送到第一个ViewControl

ios - 设置变量后 UICollectionView 为 nil

当设置了变量时,CollectionView为nil。如果我在viewDidLoad中运行,一切正常。我试图修复并搜索所有相关帖子,但我无法通过。这是我的相关代码:@IBOutletvarvnexpressContentCV:UICollectionView!varlink:String?{didSet{fetchData()}}overridefuncviewDidLoad(){super.viewDidLoad()print("viewDidLoad")vnexpressContentCV.register(UINib(nibName:"VNExpressContentCollec

ios - FireBase PhoneAuth 线程 1 : Fatal error: Unexpectedly found nil while unwrapping an Optional value

我尝试从firebase设置PhoneAuth,但我是新的,我只是不知道为什么会这样这是部分代码letcredential:PhoneAuthCredential=PhoneAuthProvider.provider().credential(withVerificationID:defaults.string(forKey:"AuthVID")!,verificationCode:self.codeInputField.text!)HereiserrorWhatXcodeshowsabouterror我认为问题出在这里,但我不知道如何解决Printingdescriptionofcr

ios - URLSession 数据任务返回 nil 响应 - 404 页面未找到

我正在尝试在Swift4中使用URlSession调用https请求。我没有收到错误,但收到了nil响应。我尝试在plist中添加ATS。添加了TLS版本、NSIncludesSubdomainskey等。仍然不起作用。不确定可能是什么问题。有帮助吗?下面是我的代码:url=URL(string:"https://quickweb.support.qvalent.com/OnlinePaymentServlet3")leturlRequest=URLRequest(url:url!,method:method,body:data.toEncodedData(),cachePolicy:

iphone - 为什么 UIMenuItem Action 的发送者总是 nil?

我已将UIMenuItem实例添加到UIMenuController。当我在文本字段中点击两次时,我会看到带有复制、剪切、粘贴、在维基百科中查找的文本编辑菜单。这是我的操作方法:-(void)lookupInWikipedia:(id)sender{NSLog(%@"lookupInWikipedia:sender=%@",sender);}当我选择“在维基百科中查找”菜单项时,我得到了NSLog。但发件人始终为零。即使是-canPerformAction:withSender:方法也不会接收除nil以外的任何发送者。-(BOOL)canPerformAction:(SEL)actio

ios - 搜索数据模型资源时的 nil 路径

我正在关注Apple的CoreDataTutoriol,但将其实现到我自己的项目中,这意味着我还没有开始使用CoreStorageData创建项目。所以我一直在复制和粘贴很多应该自动为我制作的东西,但我遇到了问题。我收到这个错误:*Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'*-[NSURLinitFileURLWithPath:]:nilstringparameter'在这个函数中发生的事情:-(NSManagedObjectModel*)managedObjectModel{if(

iphone - ManagedObjectModel 初始化为 nil

只需使用CoreData创建一个新的iPhone应用程序。我的应用程序构建时没有任何警告或错误,并且其中也包含我的.xcdatamodeld,它没有任何错误或警告。出于某种原因,我的managedObjectModel无法初始化,我也不知道为什么。-(NSManagedObjectModel*)managedObjectModel{if(__managedObjectModel){return__managedObjectModel;}NSURL*modelURL=[[NSBundlemainBundle]URLForResource:@"BAK"withExtension:@"mom