How to embed iPhone-Wax into app

馋奶兔 提交于 2019-12-03 10:17:44

If I understand correctly, you want to create an ad-hoc Lua class?! It is as simple as this:

you have a Lua script (script.lua):

waxClass{"LuaClass"}
function myMethod(self, object)
 object:doSomething()
end

and in your obj-c code:

...
luaL_dofile(wax_currentLuaState(), "script.lua");
MyClass *o = [[MyClass alloc] init];
Class LuaClass = NSClassFromString(@"LuaClass");
id luaObject = [[LuaClass alloc] init];
[luaObject performSelector:@selector(myMethod:) withObject:o];
...

Check this gist wrote by Corey.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!