[main.lua]
local library = require "plugin.library" ... library.getData( data )
[XCode project ~ PluginLibrary.mm]
int PluginLibrary::getData( lua\_State \*L ) { // double d = lua\_tonumber(L, -1); // int i = lua\_tointeger(L, -1); // boolean b = lua\_toboolean(L, -1); // NSString s = [NSString stringWithUTF8String:lua\_tostring(L, -1)]; NSData \*data = (NSData \*)lua\_touserdata(L, -1); \<---------------- 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?