I recently came across something weird that i can't wrap my head around.
i was using a SearchBar as a UI element. (note: it is the UIView subclass and not UIViewController subclass that apple handily gives out.
But i wasn't able to assign the the delegate in the computed property but was able to in viewDidload().
@usesAutoLayout var imageSearchbar:UISearchBar = {
let bar = UISearchBar()
bar.delegate = self
bar.searchBarStyle = .minimal
bar.searchTextField.backgroundColor = .white
return bar
}()
bar.delegate = self shows a compile time error
Cannot assign value of type '(CollectionViewController) -> () -> CollectionViewController' to type 'UISearchBarDelegate?'
I want to gain knowledge as to what is it that i'm missing. Help appreciated.