Joh*_*ith 16 iphone lua objective-c iphone-wax
我刚刚了解了iPhone-Wax(感谢SO).现在文档对于我想要做的事情来说相当稀疏.
我想将它嵌入到Objective-C应用程序中.我不希望它成为主要的应用程序.有没有人做过,我怎么能实现它?
我想以与使用LuaObjectiveCBridge相同的方式使用它.
如果我理解正确的话,你想创建一个临时的 Lua 类?!就这么简单:
你有一个 Lua 脚本(script.lua):
waxClass{"LuaClass"}
function myMethod(self, object)
object:doSomething()
end
Run Code Online (Sandbox Code Playgroud)
在你的 obj-c 代码中:
...
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];
...
Run Code Online (Sandbox Code Playgroud)
检查科里写的这个要点。
| 归档时间: |
|
| 查看次数: |
1327 次 |
| 最近记录: |