Lua and Objective-C: lua_pushlightuserdata() - how shall we handle the userdata object release?
The code snippet:
MyUIView *view = [[MyUIView alloc] initWithFrame:CGRectMake(0,0,100,100)];
lua_pushlightuserdata(L, view);
I keep a reference inside Lua for the开发者_Go百科 view
object. Shall I release it from Objective-C? Does Lua retain it?
If you want Lua to manage the lifetime of your object, you should use full userdata.
But, even then Lua is in plain C and does not know anything about Objective-C stuff, so it will not retain anything without your help.
精彩评论