有几个使用 FSEvent 来监听文件系统变化的例子。
如何侦听文件系统更改 MAC - kFSEventStreamCreateFlagWatchRoot
和
当使用它们创建事件时,FSEventStreamCreate
它们似乎都可以很好地传递回调项。没有参数或任何东西,只是&feCallback
. 基本上,如果有意义的话,它们似乎传递的是变量而不是函数。
但是Use of Undeclared identifier
当我尝试这样做时出现错误。是什么赋予了?
FSEventStreamRef stream = FSEventStreamCreate(NULL,
&feCallback, // what does '&' mean? Why are no parameters passed?
&cntxt,
pathsToWatch,
kFSEventStreamEventIdSinceNow,
1,
kFSEventStreamCreateFlagWatchRoot );
然后有回调函数:
static void feCallback(ConstFSEventStreamRef streamRef,
void* pClientCallBackInfo,
size_t numEvents,
void* pEventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
NSLog(@"The file changed!");
}
我想要一些示例代码来让开源帮助器对象在这里工作:https ://bitbucket.org/boredzo/fs-notifier/overview
但同样的事情。它有以下方法:
- (id) initWithCallback:(FSEventStreamCallback)newCallback path:(NSString *)newPath;
newCallback
由于上述错误,我无法通过它。