前端之家收集整理的这篇文章主要介绍了
Swift 成员变量的get/set,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import UIKit
class Question: NSObject {
var answer: String!
var icon: String!
var title: String!
var options: [String]!
var image: UIImage {
get {
return UIImage(named: self.icon)!
}
set {
self.image = newValue
}
}
lazy private var questions: [AnyObject] = {
return ["quetion1","quetion2","quetion3"]
}()
init(data: [String : AnyObject]) {
super.init()
self.setValuesForKeysWithDictionary(data)
}
}
原文链接:https://www.f2er.com/swift/325856.html