Instance member cannot be used on type

后端 未结 8 1911
遥遥无期
遥遥无期 2020-11-29 04:13

I have the following class:

class ReportView: NSView {  
    var categoriesPerPage = [[Int]]()
    var numPages: Int = { return categoriesPerPage.count }
}
<         


        
8条回答
  •  星月不相逢
    2020-11-29 05:06

    Just in case someone really needs a closure like that, it can be done in the following way:

    var categoriesPerPage = [[Int]]()
    var numPagesClosure: ()->Int {
        return {
            return self.categoriesPerPage.count
        }
    }
    

提交回复
热议问题