I wonder what would be an equivalent of
+[NSString stringWithContentsOfURL:usedEncoding:error:]
in CoreFoundation?
我知道我可以使用 (__Bridge NSString *)
的东西,这次我宁可把我的生活搞复杂一点,
在我的品味上,我很难品味有几条线 在目标C做东西
...
CFErrorRef error = NULL;
CFURLRef fileURL = CFBundleCopyResourceURL(bundle,
CFSTR("file"),
CFSTR("txt"),
NULL);
// Ugly piece of objc code in my whole C source file :(
NSError *nsError = (__bridge NSError *)(error);
NSString *nsString = [NSString stringWithContentsOfURL:(__bridge NSURL *)fileURL
usedEncoding:NULL
error:&nsError];
CFStringRef fileContents = (__brigde CFStringRef)nsString;
...