1
如果數組中的任何對象的「isSelected」屬性發生更改,我想更改數組中所有對象的「isSelected」屬性的值。我想在willSet事件中做到這一點。我有問題,如何獲取「isSelected」屬性的willSet事件中的數組(引用該對象)的引用。如果任何屬性值被修改,則更改數組中所有屬性的值swift(wiiSet)
class Survey: NSObject {
var question = "N/A"
var options = [SurveyOption]()
init(Question question:String,options:[String]) {
self.question = question
self.options.appendContentsOf(SurveyOption.GetSurveyOption(options))
}
class SurveyOption: NSObject {
var option = "N/A"
var isSelected = false
init(Option option:String) {
self.option = option
}
class func GetSurveyOption(options:[String]) -> [SurveyOption]{
var surveyOptions = [SurveyOption]()
for option in options{
surveyOptions.append(SurveyOption(Option: option))
}
return surveyOptions
}
}
class func GetSurveyQuestions() -> [Survey]{
let questions = [Survey]()
return questions
}
}