Xcode6 beta 7 Swift无法使用UIPickerViewDataSource

时间:2014-09-06 12:38:32

标签: xcode swift beta uipickerviewdatasource

每当我以这种方式添加UIPickerViewDataSource时,使用Xcode6 beta 7

class MyClassVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

它给我一个编译错误说

"Type MyClassVC does not conform to protocol UIPickerViewDataSource"

显然它适用于Beta 6,有人遇到过这个问题吗?

1 个答案:

答案 0 :(得分:4)

Xcode 6 beta 6和Xcode 6 beta 7之间的各种UIPickerViewDelegateUIPickerViewDataSource方法声明已经更改。为什么?大多数Implicitly Unwrapped Optionals参数已被Optional或Non Optional参数替换。

例如,以下声明:

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

现在是:

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

检查UIPickerViewDelegate中的不同UIPickerViewDataSourceUIViewControllers方法声明。