EXC_BAD_ACCESS

35 views
Skip to first unread message

CAI

unread,
Feb 9, 2012, 1:27:19 AM2/9/12
to iPhone Wax
lua_State *L = wax_currentLuaState();
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,
YES);
const char *file = [[[paths objectAtIndex:0]
stringByAppendingPathComponent:@"main.lua"] UTF8String] ;

int a = luaL_dofile(L,file);
if(a != 0){
printf("%s\n", lua_tostring(L, -1));
}else{
lua_getglobal(L, "_view"); // _view =
UILabel:initWithFrame(....)
lua_getglobal(L, "_str");
UILabel *luaView = (UILabel*)lua_touserdata(L, -2);
char *str = lua_tostring(L, -1);
printf("%s\n", str); // good
[self.view addSubview:luaView];// EXC_BAD_ACCESS appears here.
}


If I miss something when using Lua this way?

CAI

unread,
Feb 9, 2012, 3:33:59 AM2/9/12
to iPhone Wax
I found this:

there is function named toobjc:
id *instancePointer = wax_copyToObjc(L, "@", 1, nil);
id instance = *(id *)instancePointer;
I convert luaView with these , and it works
but i don't know why

CAI

unread,
Feb 9, 2012, 3:54:15 AM2/9/12
to iPhone Wax
OK, I got it.

just because wax wrapped Objc objects as "wax_instance_userdata"
Reply all
Reply to author
Forward
0 new messages