samedi 9 mai 2015

Call Swift Callback in C [duplicate]

This question already has an answer here:

I have the following code in .c file:

void logger(void (*callback_func)())
{
    callback_func();
}

How do I call this function from swift code?

func callback()
{
    NSLog("Hello from Swift")
}

func main()
{
    logger(callback)
}

It works to call C function from Swift but I can't get it to work if it has a callback function as an argument.

Aucun commentaire:

Enregistrer un commentaire