I want to add a category on NSBezierPath to return a CGPathRef for the path. Since this is a core foundation object, I cannot autorelease it, and the caller of the method is responsible for releasing it. By placing either "Copy" or "Create" as part of the method name, I think I am following the convention set by Apple here: https://developer.apple.com/library/mac/#documentation/CoreFOundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html
However, the static analyzer won't accept it unless I go even further, and—not only include create/copy as part of the name, but—actually start the method name with "copy" (or mutableCopy, etc).
However, doing so is in violation of best practice for naming category methods, as they should be prefixed to avoid naming collision.
What is the best way of achieving all of the following:
Something like this you mean:
//
// NSBezierPath+MCAdditions.h
//
// Created by Sean Patrick O'Brien on 4/1/08.
// Copyright 2008 MolokoCacao. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "AnalyzerMacros.h"
@interface NSBezierPath (MCAdditions)
+ (NSBezierPath *)bezierPathWithCGPath:(CGPathRef)pathRef;
- (CGPathRef)cgPath CF_RETURNS_RETAINED;
- (NSBezierPath *)pathWithStrokeWidth:(CGFloat)strokeWidth;
- (void)fillWithInnerShadow:(NSShadow *)shadow;
- (void)drawBlurWithColor:(NSColor *)color radius:(CGFloat)radius;
- (void)strokeInside;
- (void)strokeInsideWithinRect:(NSRect)clipRect;
@end
It's not my code; I added the CF_RETURNS_RETAINED
to help the static analyzer out.
The full reference to clang source annotations is available here.