我的项目不是 arc 或 cocoa,所以我不想NSString
在我的代码中使用,但它似乎不起作用。Xcode 显示"ERROR: (CFStringGetTypeID() != CFGetTypeID(cfStringRef)) (i = 0)"
. 我应该如何创建 CFString?
代码如下:
const char *path = m_directory.AsCharPtr();
CFStringRef directory = CFStringCreateWithCString(kCFAllocatorDefault,path,kCFStringEncodingUTF8);
CFArrayRef pathsToWatch = CFArrayCreate(kCFAllocatorMalloc, (const void **)directory, 1, NULL);
void *appPointer = this;
FSEventStreamContext context = {0, appPointer, NULL, NULL, NULL};
FSEventStreamRef stream;
CFAbsoluteTime latency = 1.0; /* Latency in seconds */
/* Create the stream, passing in a callback */
stream = FSEventStreamCreate(NULL, &fsevents_callback,
&context,
pathsToWatch,
kFSEventStreamEventIdSinceNow, /* Or a previous event ID */
latency,
kFSEventStreamCreateFlagFileEvents /* Flags explained in reference */
);