Swift 1.2 / Xcode 6.3.
Why is this valid:
class RangeDelegateNongeneric: NSObject, UIPickerViewDataSource {
var values = [Int]()
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return values.count
}
}
but this isn't:
class RangeDelegateGeneric<T>: NSObject, UIPickerViewDataSource {
var values = [T]()
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return values.count
}
}
Error: Type RangeDelegateGeneric<T> does not conform to protocol UIPickerViewDataSource
Even more oddly, the Fix-it message: Candidate is not @objc, but protocol requires it
prepends @objc
to the beginning of each function, but that doesn't Fix-it, and the Fix-it tool is happy to repeatedly prepend @objc
!