Reputation: 11
import UIKit
func Question() {
var questiontext : String
var answer : Bool
init(text: String , correctanswer: Bool ){ //error in this point : Initializers may only be declared within a type
questiontext = text
answer = correctanswer
}
}
How can I solve this problem?
Upvotes: 0
Views: 1230
Reputation: 100541
An init
should be inside class
/ struct
type not func
class Question {
var questiontext : String
var answer : Bool
init(text: String , correctanswer: Bool ){
questiontext = text
answer = correctanswer
}
}
Upvotes: 3