diff --git a/extensions/scripting/lua-bindings/manual/platform/ios/CCLuaObjcBridge.mm b/extensions/scripting/lua-bindings/manual/platform/ios/CCLuaObjcBridge.mm index 8400cbc06d..84fa604c5b 100644 --- a/extensions/scripting/lua-bindings/manual/platform/ios/CCLuaObjcBridge.mm +++ b/extensions/scripting/lua-bindings/manual/platform/ios/CCLuaObjcBridge.mm @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2022 Bytedance Inc. https://adxeproject.github.io/ @@ -43,7 +44,17 @@ static void luaTableToObjcDictionary(lua_State* L, NSMutableDictionary* dict, NS lua_pushnil(L); while (lua_next(L, -2)) { - NSString* key2 = [NSString stringWithCString:lua_tostring(L, -2) encoding:NSUTF8StringEncoding]; + NSString* key2 = nil; + int keyType = lua_type(L, -2); + if (keyType == LUA_TSTRING) + key2 = [NSString stringWithCString:lua_tostring(L, -2) encoding:NSUTF8StringEncoding]; + else if (keyType == LUA_TNUMBER) + key2 = [[NSNumber numberWithInt:lua_tonumber(L, -2)] stringValue]; + else + { + lua_pop(L, 1); + continue; + } switch (lua_type(L, -1)) {