Xcode 6 tells me that UIViewController has no member named reloadData ()
I have a view controller that is UICollectionViewController
, UICollectionViewDataSource
and UICollectionViewDelegate
.
After updating Xcode recently, I get the following error:
'(UICollectionView, numberOfItemsInSection: Int) -> Int' has no member named 'reloadData'
in the following code ( -didCompleteForecast:
- callback method):
func didCompleteForecast() {
//stuff
println("got the data back")
dispatch_async(dispatch_get_main_queue()) {
self.collectionView.reloadData()
}
According to Apple's own documentation, -reloadData:
should be available.
What am I missing?
thank
source to share
You might get an error like this if you're dealing with a standard UIViewController
to which you've added a collection view but neglected to define an outlet / property function called collectionView
.
In this situation, the reference collectionView
in didCompleteForecast
will match the first method UICollectionViewDelegate
that you implemented in your class (presumably a method numberOfItemsInSection
based on your error message).
As Aditya correctly pointed out, you will also get this error with help UICollectionViewController
if you don't expand the optional collectionView
.
source to share