I had a weird problem running into considering a header of a UICollectionView
.
I basically used the code from: http://www.raywenderlich.com/78551/beginning-ios-collection-views-swift-part-2
func collectionView(collectionView: UICollectionView,
viewForSupplementaryElementOfKind kind: String,
atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy' - 'HH:mm'"
//1
switch kind {
//2
case UICollectionElementKindSectionHeader:
//3
let h =
collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "eventHeaderView", forIndexPath: indexPath) as eventHeader
h.eventFirstline.text = "First Line"
h.eventSecondline.text = thisEvent.eventName
h.eventDate.text = dateFormatter.stringFromDate(thisEvent.startDate)
h.eventDescription.text = thisEvent.shortDescription
return h
default:
//4
assert(false, "Unexpected element kind")
}
}
All that works perfectly fine when instantly deploying to either the simulator or a real device, but oddly when I wanna build an Ad-Hoc Package for testing purposes it tells me
Missing return in a function expected to return 'UICollectionReusableView'
Ok so far so good, there is nothing outside the switch-case so it could return nothing - but why does it not give any warnings on "hot deploy" only when I try to build a package?