LUA_API voID (lua_setuservalue) (lua_State *L,int IDx);typedef int (*lua_CFunction) (lua_State *L);LUA_API voID (lua_callk) (lua_State *L,int nargs,int nresults,int ctx,lua_CFunction k);
我使用桥接头来访问库,从我的Swift代码中我可以毫无困难地调用lua_setuservalue.但是,如果我尝试调用lua_callk,我会“使用未解析的标识符’lua_callk’”.如果我从lua_callk的声明中删除函数指针,我不再收到此错误.任何帮助都非常感谢.
解决方法 从beta 3开始,Apple已经提供了函数指针,但是它们只能被引用而不能被调用.Using Swift with Cocoa and Objective-C
Function PointersC function pointers are imported into Swift as
CFunctionPointer<Type>
,whereType
is a
Swift function type. For example,a function pointer that has the typeint (*)(voID)
in C
is imported into Swift asCFunctionPointer<() -> Int32>
Beta 3 Release Notes(pdf)
总结Function pointers are also imported Now,and can be referenced and passed around. However,you cannot call a C function pointer or convert a closure to C function pointer type.
以上是内存溢出为你收集整理的ios – Swift不能与函数指针一起使用吗?全部内容,希望文章能够帮你解决ios – Swift不能与函数指针一起使用吗?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)