How to embed iPhone-Wax into app

后端 未结 1 1691
忘了有多久
忘了有多久 2021-02-13 01:49

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\

1条回答
  •  礼貌的吻别
    2021-02-13 02:16

    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.

    0 讨论(0)
提交回复
热议问题