Fix type resolving for method starting with "new.."?


I'm using Mike Ash's KVO Extensions which define a property called 'newValue' (of type 'id').

The property getter does not create a new object, which is marked by '__attribute__((ns_returns_not_retained))' in its definition.

(Both Xcode's and AppCode's analyzers don't complain about a memory leak or such)

However, it seems AppCode's analyzer assumes the returned type is the same type as the owning object (which is typical of 'new..' family methods),

and complains about invalid selectors - see screenshot

Screen Shot 2015-08-11 at 14.39.14.png

For completeness, here is the object's interface (full source is available at the link above):

@interface MAKVONotification : NSObject

@property(copy,readonly) NSString   *keyPath;

@property(assign,readonly) id     observer, target;

@property(assign,readonly) NSKeyValueChange kind;

@property(strong,readonly) id     oldValue;

@property(strong,readonly) id __attribute__((ns_returns_not_retained)) newValue;

@property(strong,readonly) NSIndexSet   *indexes;

@property(assign,readonly) BOOL    isPrior;


So my question - is there a way to fix this? Obviously I can fork the project and rename the property, but is there a way to tell AppCode to not assume the type? Is this a bug in AppCode?


Please sign in to leave a comment.