是什么导致 AppCode 中的 "Method 'foo' is defined in class 'Bar' and is not visible"
What causes "Method 'foo' is defined in class 'Bar' and is not visible" in AppCode
给定以下方法:
- (void)sendEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0)
{
_lastUserTouchTime = [[NSDate date] timeIntervalSince1970];
}
[super sendEvent:event];
}
[event allTouches] 在 AppCode 2016.3 中生成以下检查警告。
"Method 'allTouches' is defined in class 'UIEvent' and is not visible"
allTouches 是在 中定义的,我已尝试将其包括在内但没有效果。 Xcode 这段代码似乎没有任何问题。有人对此有见解吗?
那是因为 allTouches
被定义为 属性
看这段代码:
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
iOS SDK 的更高版本使用属性而不是方法。而且,AppCode 的类型检查比 Xcode 更严格。这就是为什么 Xcode 静默编译并且 AppCode 给出警告
给定以下方法:
- (void)sendEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0)
{
_lastUserTouchTime = [[NSDate date] timeIntervalSince1970];
}
[super sendEvent:event];
}
[event allTouches] 在 AppCode 2016.3 中生成以下检查警告。
"Method 'allTouches' is defined in class 'UIEvent' and is not visible"
allTouches 是在
那是因为 allTouches
被定义为 属性
看这段代码:
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
iOS SDK 的更高版本使用属性而不是方法。而且,AppCode 的类型检查比 Xcode 更严格。这就是为什么 Xcode 静默编译并且 AppCode 给出警告