How to embed iPhone-Wax into app
Asked Answered
Y

1

16

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

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?

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

Yandell answered 13/5, 2010 at 1:39 Comment(3)
Welcome to iPhone Wax mailing list: groups.google.com/group/iphonewax?pli=1Sensor
Thanks, I've posted the question there, and trying some stuff here as well.Yandell
related: https://mcmap.net/q/821237/-lua-on-the-iphoneHolmgren
S
3

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.

Stopoff answered 29/10, 2011 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.