xcodeswiftbetauipickerviewdatasource

Xcode6 beta 7 Swift cannot use UIPickerViewDataSource


With Xcode6 beta 7 whenever i add the UIPickerViewDataSource in this way

class MyClassVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

it gives me a compile error saying

"Type MyClassVC does not conform to protocol UIPickerViewDataSource"

Obviously it worked with Beta 6, anyone faced this problem?


Solution

  • The various UIPickerViewDelegate and UIPickerViewDataSource methods declarations have been changed between Xcode 6 beta 6 and Xcode 6 beta 7. Why? Most of Implicitly Unwrapped Optionals parameters have been replaced with Optional or Non Optional parameters.

    For example, the following declaration:

    func pickerView(_: UIPickerView!, titleForRow row: Int, forComponent component: Int) -> String! {
        return "Hello"
    }
    

    is now:

    func pickerView(_: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
        return "Hello"
    }    
    

    Check for your different UIPickerViewDelegate and UIPickerViewDataSource methods declarations in your UIViewControllers.