Search code examples
objective-cmemory-leakscore-text

CTFontCopyFamilyName() causes leak


I am developing a program, that uses Core Text... And I have a leak in the following line of code:

NSString *familyName = (NSString*)CTFontCopyFamilyName(font);

When I write CFRelease((CFStringRef)familyName); I get bad access exception. When I write [familyName release]; I have the same issue. Can anyone help me please?


Solution

  • Use -

    NSString *familyName = [(NSString*)CTFontCopyFamilyName(font) autorelease];