objective c - Dereference pointer with ARC in C function in iOS -


i'm using amazing audio engine handle playback in syncing in ios app.

the framework requires use c functions call (playbacktimingreceiver) called on audio thread. need message main thread again using c function (aeaudiocontrollersendasynchronousmessagetomainthread) pass handler (pageturnhandler).

i'm not overly experienced working c understand i'm passing pointer in message needs dereferenced.

which can achieve line:

playbackmanager* receiver = *((playbackmanager**)userinfo); 

but if turn arc off in project file using -fno-objc-arc flag in compiled sources on projects target.

to question, possible achieve arc turned on? if correct syntax?

relevant code segment:

#pragma mark - audio timing callback -(aeaudiocontrollertimingcallback)timingreceivercallback {     return playbacktimingreceiver; }  static void playbacktimingreceiver(playbackmanager* receiver,                                    aeaudiocontroller *audiocontroller,                                    const audiotimestamp *time,                                    uint32 const frames,                                    aeaudiotimingcontext context) {     receiver->_hosttime = getuptimeinmilliseconds(time->mhosttime);     aeaudiocontrollersendasynchronousmessagetomainthread(audiocontroller,                                                          pageturnhandler,                                                          &audiocontroller,                                                          sizeof(id)); }  static void pageturnhandler(aeaudiocontroller *audiocontroller, void *userinfo, int userinfolength) {     playbackmanager* receiver = *((playbackmanager**)userinfo);     nslog(@"receiver:%@", receiver); } 

playbackmanager * receiver = (__bridge_transfer id)*(void **)userinfo; 

should trick. first casts userinfo pointer-to-pointer, because contains address of original object pointer. dereference original pointer, , use __bridge_transfer type -- id or playbackmanager work -- tell arc dereferenced value object needs take care of.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -