开发者

Lua and Objective-C: lua_pushlightuserdata() - how shall we handle the userdata object release?

开发者 https://www.devze.com 2023-01-31 21:28 出处:网络
The code snippet: MyUIView *view = [[MyUIView alloc] initWithFrame:CGRectMake(0,0,100,100)]; lua_pushlightuserdata(L, view);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消