import UIKit
class Demo{
var url:NSString
//被lazy修饰后。当该变量被使用到的时候。才会执行等号后面的闭包语句
lazy var completURL:NSString = {
[unowned self] in
if self.url.hasPrefix("http://"){
return self.url
}
else{
return "http://\(self.url)" as NSString
}
}()
init(url:NSString){
self.url=url
}

}
let demo=Demo(url:"www.yzdzy.com")
demo.url
demo.completURL