David Nedrow
David Nedrow

Reputation: 1158

What causes "Method 'foo' is defined in class 'Bar' and is not visible" in AppCode

Given the following method:

- (void)sendEvent:(UIEvent *)event
{
    NSSet *allTouches = [event allTouches];

    if ([allTouches count] > 0)
    {
        _lastUserTouchTime = [[NSDate date] timeIntervalSince1970];
    }

    [super sendEvent:event];
}

The [event allTouches] generates the following inspection warning in AppCode 2016.3.

"Method 'allTouches' is defined in class 'UIEvent' and is not visible"

allTouches is defined in <UIKit/UIEvent.h> which I've tried including to no effect. Xcode doesn't seem to have any issue with this bit of code. Anyone have insight on this?

Upvotes: 0

Views: 365

Answers (1)

GRiMe2D
GRiMe2D

Reputation: 664

Thats because allTouches is defined as property

Look at this code:

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIEvent : NSObject
...
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly, nullable) NSSet <UITouch *> *allTouches;
#else
- (nullable NSSet <UITouch *> *)allTouches;
#endif
...
@end

Later versions of iOS SDK uses properties rather than methods. And, AppCode has more strict type-checks than Xcode. That's why Xcode silently compiles and AppCode gives warnings

Upvotes: 1

Related Questions