As FSEventStreamCreate is only available on macOS, you may do it the following way:
// call this in init of your app delegate
FSEventStreamContext cntxt = {0, (__bridge void *)(self), NULL, NULL, NULL};
// call FSEventStreamCreate as in your code
// keep a reference to the stream so you can stop and start it later
Then in your callback the AppDelegate will be in:
YourAppDelegateClass* appDele = (__bridge YourAppDelegateClass*)pClientCallBackInfo;
The whole mechanism for FSEvents is quite complex, we had to schedule it on the right run loop and work with ARC and type casting. The callback is outside of ObjectiveC, you won't be able to use Cocoa but only CFString and other Core Foundation types. It's also helpful to not only read the documentation but look at the FSEvents.h within the Framework (context menu on any of the functions and then Jump to definition: There is more to read than in the documentation). And depending on your distribution, also work with the App Store Sandbox and security scoped bookmarks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…