How to implement sqlite3_trace callback in objective c
I'm having trouble implementing following callback from the sqlite3 api. Has someone a good 开发者_运维百科example for implementing callbacks like this?
void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
Found the solution: (this goes before @implementation block)
void myCallbackFunc(void *foo, const char* bar) {
NSLog(@"=> %s", bar);
}
Essentially, implement a function with the following signature:
void (*xTrace)(void*,const char*);
and then place a pointer to this function in the call to sqlite3_trace. The sqlite3_trace page tells you what values will be passed to this function, so that you can NSLog then, [fs]printf them, show them on the screen, whatever you would like
精彩评论