阅读背景:

如何正确使用CFRetain和CFRelease?

来源:互联网 

Here's some sample code:

这是一些示例代码:

@interface Foo : NSObject
{
    CFAttributedStringRef m_foo;
}
@property (nonatomic, assign) CFAttributedStringRef foo;
@end

@implementation Foo
@synthesize foo = m_foo;

- (id)initWithAttributedString:(CFAttributedStringRef)attributedString
{
    self = [super init];
    if (self == nil)
        return nil;

    if (attributedString != NULL)
    {
        self.foo = CFAttributedStringCreateCopy(NULL, attributedString);
    }

    return self;
}

- (void)dealloc
{
    if (self.foo != NULL)
        CFRelease(self.foo);

    [super dealloc];
}

@end
@interfa



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: