我有一个问题,当我建立我的应用在迅速2. Xcode中说:斯威夫特:错误:初始化(编码器:)'“需要”初始化必须的子类来提供“的UIView”
3210这是类的代码:
class creerQuestionnaire: UIView {
@IBOutlet weak var nomQuestionnaire: UITextField!
@IBOutlet weak var question: UITextField!
@IBOutlet weak var reponse: UITextField!
var QR: Questionnaire
@IBAction func creerQuestion(sender: AnyObject) {
QR.ajouterQuestion(question.text!, nouvReponse: reponse.text!)
}
}
,这是类问卷:
import Foundation
class Questionnaire {
var QR = [String(), String()]
func getQuestion(nbQuestion: Int) ->String {
return QR[nbQuestion]
}
func getReponse(nbReponse: Int) ->String {
return QR[nbReponse]
}
func ajouterQuestion(nouvQuestion: String, nouvReponse: String) {
QR += [nouvQuestion, nouvReponse]
}
}
的Merci!
为什么是一个'override'和其他'必需'? –
@MichaelDautermann我刚刚添加了一些关于required和override的信息。感谢您的关注。 – Allen
感谢您的回复! –