寻求一些有关从 Corona OOP 类外部访问变量的帮助。这是基本代码:
module(..., package.seeall)
local widget = require "widget"
picker = {}
picker.__index = picker
function picker.new()
local picker_object = {}
setmetatable(picker_object,picker)
picker_object.theHour = 12
picker_object.theMin = 0
picker_object.am = true
return picker_object
end
function picker:getHour()
return self.theHour
end
function picker:getMin()
return self.theMin
end
当我尝试从课堂外调用 getHour 和 getMin 时,self 以 nil 的形式返回。我应该使用什么语法来返回我的 theHour 和 theMin 变量?谢谢!!