Not sure why but this crashes with bad access starting in Catalina (not on previous versions of the OS):
CFStringRef path = (__bridge CFStringRef)(self.someURL.path);
CFArrayRef pathsToWatch = CFArrayCreate(NULL,
(const void **)&path,
1,
NULL);
FSEventStreamRef stream;
stream = FSEventStreamCreate(NULL,
&theFunction,
&context,
pathsToWatch,
kFSEventStreamEventIdSinceNow,
1.0,
flags); //<--CRASH here.
Now if I create the path CFStringRef like below instead, I do not get a crash:
NSString *nsStringP = self.someURL.path;
CFStringRef path = (__bridge CFStringRef)(nsStringP);
CFArrayRef pathsToWatch = CFArrayCreate(NULL,
(const void **)&path,
1,
NULL);
FSEventStreamRef stream;
stream = FSEventStreamCreate(NULL,
&theFunction,
&context,
pathsToWatch,
kFSEventStreamEventIdSinceNow,
1.0,
flags); //<-- no crash here.
Only difference here is that I just put the returned value from the path getter in a local variable. Not sure why the compiler wouldn't generate the same code in both cases here?