How get and pass parameter data in lua from Objective-C and vice versa?

[main.lua]

local library = require "plugin.library" ... library.getData( data )

[XCode project ~ PluginLibrary.mm]

int PluginLibrary::getData( lua\_State \*L ) { &nbsp;&nbsp; // double d = lua\_tonumber(L, -1); &nbsp;&nbsp; // int i = lua\_tointeger(L, -1); &nbsp;&nbsp; // boolean b = lua\_toboolean(L, -1); &nbsp;&nbsp; // NSString s = [NSString stringWithUTF8String:lua\_tostring(L, -1)]; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; NSData \*data = (NSData \*)lua\_touserdata(L, -1);&nbsp; \<---------------- Is correct get? return 0; }

And pass nsdata from Obj-C to lua:

int PluginLibrary::passData( lua\_State \*L ) { CoronaLuaNewEvent( L, "methodName"); //.... Parameters .....// lua\_pushnumber(L, value); [work] lua\_setfield(L, -2, "parameterName"); lua\_pushinteger(L, value); [work] lua\_setfield(L, -2, "parameterName"); lua\_pushstring(L, value); [work] lua\_setfield(L, -2, "parameterName"); . . UIImage \*image = [UIImage imageNamed:@"imageName.png"]; NSData \*imageData = [NSData dataWithData:UIImagePNGRepresentation(image)]; lua\_pushlightuserdata(L, imageData); \<----- Is correct pass to lua? CoronaLuaDispatchEvent(L, listener, 0); }

Or how get and pass data from Lua to Obj-C and vice versa?