I’m trying to pass an object method as a parameter, essentially as a callback function for a network request in another class.
[lua]
function ItemManager:loadData()
--print(tostring(self:getItemData))
--cant pass with the : sytax
Parse.getItems(self.getItemData)
end
[/lua]
This in turn should call the following function/method when the network request is finished.
[lua]
function ItemManager:getItemData(data)
print("ItemManager: data - "…data.response)
self.data = data.response
end
[/lua]
The problem is that I can’t pass the function as a method with the : syntax, and if I attempt to pass it with a . it doesn’t fire the call.
I need getItemData to be a method because it needs to access the object’s properties.
Does anybody know how to handle this situation; or perhaps an alternative way of dealing with this?
Many thanks…