ios - Swift: Calling instance method using class name -
i reading ios programming: big nerd ranch guide.i on chapter 10 , in chapter reading adding new row in tableview. need call
itemstore.createitem()
here itemstore class
class itemstore { var allitems = [item]() func createitem() -> item{ let newitem = item(random: true) allitems.append(newitem) return newitem } init(){ _ in 0..<5{ createitem() } } }
but mistake have typed class name itemstore , after dot xcode gave me option
() -> item createitem(self: itemstore)
and have managed same thing this
let newitem = itemstore.createitem(itemstore)()
so class method coming? syntax sugar? significance this?
Comments
Post a Comment