使用C编写的SDK(Linphone),我需要将在C文件中声明的调用状态更改处理函数实现为Objective-C或在Swift环境中最好。在Objective-C中实现C回调
这里是在C声明:
// declaration
void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg);
// typedef
typedef void (*LinphoneCoreCallStateChangedCb)(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
这里包含要使其实现
typedef struct _LinphoneCoreVTable{
LinphoneCoreCallStateChangedCb call_state_changed;/**<Notifies call state changes*/
} LinphoneCoreVTable;
这里需要LinphoneCoreCallStateChangedCb属性的结构是我的尝试:
_vTable->call_state_changed = ^(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message)
{
}
这是什么正确的语法?
谢谢!
你不需要实现,因为C代码*只是*在Objective-C中运行良好? – kientux
请勿将代码作为图像发布。 – dandan78