swift 使用计算属性+结构管理内存

class GooClass {

    deinit {

        print("aaaaaaaa")

    }

    var str = "gooClass"

}

 

struct GooStruct {

    var goo = GooClass()

}

 

extension ViewController{

    var gooStruct:GooStruct {

        get {

            return GooStruct()

        }

    }

}

 

class ViewController: UIViewController {

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        print(self.gooStruct.goo.str)

    }

}

posted @ 2018-09-25 15:06  zzfx  阅读(192)  评论(0编辑  收藏  举报