YYText源码阅读

2019-03-02  本文已影响0人  啵啵_long_港

一、基础知识

- (void)setFont:(UIFont *)font {
    [self _makeMutableAttributes];
    if (font == (id)[NSNull null] || font == nil) {
        ((NSMutableDictionary *)_attributes)[(id)kCTFontAttributeName] = [NSNull null];
    } else {
        CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL);
        if (ctFont) {
            ((NSMutableDictionary *)_attributes)[(id)kCTFontAttributeName] = (__bridge id)(ctFont);
            CFRelease(ctFont);
        }
    }
}
  1. CFRelease:
    If the retain count of cf becomes zero the memory allocated to the object is deallocated and the object is destroyed. If you create, copy, or explicitly retain (see the CFRetain function) a Core Foundation object, you are responsible for releasing it when you no longer need it
    如果是你创建、copy、或明确保留(explicitly retain (see the CFRetain function))的一个Core Foundation对象,你需要用CFRelease方法去释放这个Core Foundation对象。
上一篇 下一篇

猜你喜欢

热点阅读