如何将iPhone-Wax嵌入应用程序 [英] How to embed iPhone-Wax into app

查看:165
本文介绍了如何将iPhone-Wax嵌入应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚了解了iPhone-Wax(感谢SO)。现在文档对​​于我想要做的事情来说相当稀疏。

I have just learnt about iPhone-Wax (thanks to SO). Now the documentation is rather sparse for what I am trying to do.

我想将它嵌入到Objective-C应用程序中。我不希望它成为主要的应用程序。有没有人完成它,我怎么能实现它?

I want to embed it into an Objective-C app. I don't want it to be the main app. Has anyone done it and how can I achieve it?

我想以同样的方式使用LuaObjectiveCBridge。

I would like to use it in the same way LuaObjectiveCBridge is used.

推荐答案

如果我理解正确,你想创建一个特殊的Lua类?!它很简单:

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

你有一个Lua脚本(script.lua):

you have a Lua script (script.lua):

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

并在您的对象代码中:

...
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];
...

检查这个 gist 由Corey撰写。

Check this gist wrote by Corey.

这篇关于如何将iPhone-Wax嵌入应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆