使用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