Я не знаю, что случилось с моей кодировкой. Я попытался следовать учебнику, но произошла такая же ошибка.
Ошибка:
Тип "FourthViewController" не соответствует протоколу "UIPickerViewDataSource"
Вот мой код:
import UIKit
let characters = ["Jaja Bink", "Luke", "Han Solo", "Princess Leia"];
let weapons = ["LightSaber", "Pistol", "Keris"];
class FourthViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {
@IBOutlet weak var doublePicker: UIPickerView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 2
}
func pickerView(pickerView: UIPickerView,
titleForRow row: Int,
forComponent component: Int) -> String? {
if component == 0 {
return characters[row]
} else {
return weapons[row]
}
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int? {
if component == 0 {
return characters.count
} else {
return weapons.count
}
}
}