转换工程到ARC ,结果这行代码报错:
_font = CTFontCreateWithName((CFStringRef)_fontName, fontSize, NULL);
其中 _fontName是NSString,错误信息是:
Cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast
我找到了两种解决方法:
第一种:Use __bridge to convert directly (no change in ownership)
第二种:Use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')
不知道那种比较好?