The second argument to the callback function is void *info (which is context.info ), not a pointer to the FSEventStreamContext context structure.
So this code should work to get the correct pointer:
void FileWatcherCallback( ConstFSEventStreamRef streamRef, void *info, // <-- this is context.info size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
Note: It seems to me that there is another problem using CFBridgingRetain() / CFBridgingRelease() . The save counter of the uploadQueue object will decrease every time the callback function is called. This leads to a failure very quickly.
Probably better to use
context.info = (__bridge void *)(uploadQueue);
to create an event flow and
NSMutableDictionary *queue = (__bridge NSMutableDictionary *)info;
in the callback function. You only need to make sure that you keep a strong link to uploadQueue while using the event stream.
source share