转自
原文
// 原型模式
// 百度百科:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象
// 设计模式分类:创建型模式
class ChungasRevengeDisplay {
@H_403_25@var name: @H_403_25@String?
let font: @H_403_25@String
init(font: @H_403_25@String) {
@H_403_25@self@H_403_25@.font = font
}
func clone() -> ChungasRevengeDisplay {
return ChungasRevengeDisplay(font:@H_403_25@self@H_403_25@.font)
}
}
let Prototype = ChungasRevengeDisplay(font:"GotanProject")
let Philippe = Prototype@H_403_25@.clone()
Philippe@H_403_25@.name = "Philippe"
let Christoph = Prototype@H_403_25@.clone()
Christoph@H_403_25@.name = "Christoph"
let Eduardo = Prototype@H_403_25@.clone()
Eduardo@H_403_25@.name = "Eduardo"
@H_502_96@ 原文链接:https://www.f2er.com/swift/323814.html