Reputation:
I am following this tutorial .The program execution stops
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate=self /////error line
collectionView.dataSource=self /////error line
self.searchController.searchResultsUpdater = self
self.searchController.delegate = self
self.searchController.searchBar.delegate = self
self.searchController.hidesNavigationBarDuringPresentation = false
self.searchController.dimsBackgroundDuringPresentation = true
self.searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search for tools and resources"
searchController.searchBar.sizeToFit()
searchController.searchBar.becomeFirstResponder()
self.navigationItem.titleView = searchController.searchBar
// Do any additional setup after loading the view, typically from a nib.
}
the program execution stop at these two lines
collectionView.delegate=self /////error line
collectionView.dataSource=self /////error line
The error is
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
.How to get rid of this program crash.How to implement search operation on collection view.you can download the project from this link . https://drive.google.com/file/d/1ZSahZtGlfpEoo0eu40pHQHBwm9SrtU3H/view?usp=sharing
Upvotes: 0
Views: 1009
Reputation: 9923
Your collectionView
outlet have not been connected with the UICollectionView
from Storyboard, Connect them, and then it will work.
Upvotes: 1