Attempt to call field'LoadShift' (a nil value)
This is my code,
loginpage1.lua
local LoadShift = nil;
.
.
function LoadShift()
end
loginpage2.lua
local loginObj = require("com.classess.loginpage1")
loginObj.LoadShift();
What’s wrong with my code, please help me solve this problem
--- ---------Your class LoadShift---------------
local LoadShift = {}
.
.
function LoadShift:LoadShiftFunc()
--do somthing
end
.
.
return LoadShift
----------- --------------------------
Then need it and call the function
---------------------
local LoadShift = require "LoadShift"
LoadShift:LoadShiftFunc()< /pre>
When I try to call a method of another class from another class, it displays an error message,
Attempt to call field'LoadShift' (a nil value)
This is my code,
loginpage1.lua
local LoadShift = nil;
.
.
function LoadShift()
end
loginpage2.lua
local loginObj = require("com.classess.loginpage1")
loginObj.LoadShift();
What’s wrong with my code, please help me solve this problem
Make your custom class like this
----------- -Your class LoadShift---------------
local LoadShift = {}
.
.
function LoadShift:LoadShiftFunc()
--do somthing
end
.
.
return LoadShift
------------------- ------------------
Then need it and call the function
---- -----------------
local LoadShift= require "LoadShift"
LoadShift:LoadShiftFunc()
< p>