简体   繁体   English

搜索控制器在 Xcode 6.4 中不起作用

[英]Search Controller not working in Xcode 6.4

I am learning Swift and tried to create a demo app using a TableViewController with a search bar.我正在学习 Swift 并尝试使用带有搜索栏的 TableViewController 创建一个演示应用程序。 However, I am getting a EXC_BAD_INSTRUCTION error with console showing fatal error: unexpectedly found nil while unwrapping an Optional Value但是,我收到一个EXC_BAD_INSTRUCTION错误,控制台显示fatal error: unexpectedly found nil while unwrapping an Optional Value

The viewDidLoad() function is having the error viewDidLoad()函数出现错误

override func viewDidLoad()
{
    super.viewDidLoad()
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false

    //Do more stuff

}

The problem is that searchController doesn't exist.问题是searchController不存在。 Well, it exists as an instance variable , but you have not assigned that variable any value other than nil .好吧,它作为一个实例变量存在,但是您没有为该变量分配除nil之外的任何 You need to make an actual UISearchController and assign it to self.searchController .您需要制作一个实际的 UISearchController 并将其分配self.searchController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM