We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
今天写了一个 lua 调用 iOS 的同步回调遇到了这个问题。 一开始直接跟的源码,然后发现使用 NSMethodSignature 获取到的 methodReturnType 就是 'B'。 之前没怎么写过 oc 代码,所以 Google 之。
发现了在 Quick-x 最早的时候( 2 Nov 2015 )有这么一个 issue:
使用luaoc.callStaticMethod调用Objective-C方法时报错not support return type
顺便去看了一下 cocos2d-x 的源码,发现也修复了,追溯到是在 2017 年 6 月份修复的
luaoc static function return type BOOL #17956
解决方案: 使用 @encode 关键字转化来进行字符串比较。
@encode
以下是改动后的代码:
// in CCLuaObjcBridge.mm on line 123 if (returnLength > 0) { if (strcmp(returnType, @encode(id)) == 0) { id ret; [invocation getReturnValue:&ret]; pushValue(L, ret); } else if (strcmp(returnType, @encode(BOOL)) == 0) // BOOL { char ret; [invocation getReturnValue:&ret]; lua_pushboolean(L, ret); } else if (strcmp(returnType, @encode(int)) == 0) // int { int ret; [invocation getReturnValue:&ret]; lua_pushinteger(L, ret); } else if (strcmp(returnType, @encode(float)) == 0) // float { float ret; [invocation getReturnValue:&ret]; lua_pushnumber(L, ret); } else { NSLog(@"not support return type = %s", returnType); lua_pushnil(L); } }
@u0u0 麻烦看一下,谢谢。
The text was updated successfully, but these errors were encountered:
thanks,accept.
Sorry, something went wrong.
https://github.com/u0u0/Quick-Cocos2dx-Community/issues/99
c89c88e
No branches or pull requests
今天写了一个 lua 调用 iOS 的同步回调遇到了这个问题。
一开始直接跟的源码,然后发现使用 NSMethodSignature 获取到的 methodReturnType 就是 'B'。
之前没怎么写过 oc 代码,所以 Google 之。
发现了在 Quick-x 最早的时候( 2 Nov 2015 )有这么一个 issue:
使用luaoc.callStaticMethod调用Objective-C方法时报错not support return type
顺便去看了一下 cocos2d-x 的源码,发现也修复了,追溯到是在 2017 年 6 月份修复的
luaoc static function return type BOOL #17956
解决方案: 使用
@encode
关键字转化来进行字符串比较。以下是改动后的代码:
@u0u0 麻烦看一下,谢谢。
The text was updated successfully, but these errors were encountered: