I'm facing a kinda stupid problem trying to code my first swift classes. I'm writing an init method for my class, and I want to (raise an exception)/(do something in some way) to report an error when the parameters that have been passed to the initializer are wrong. My class is simple as that:
class Phrase: NSObject {
let name : String
let voices : Array<Voice>
init(name: String, voices: Array<Voice>){
if (name == "" || voices.count == 0){
//do something!
}
self.name = name
self.voices = voices
}
}
Thank you in advance!