导致“方法'foo'在类'Bar'中定义并且在AppCode中不可见”的原因

时间:2021-08-03 18:11:17

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.

[event allTouches]在AppCode 2016.3中生成以下检查警告。

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

“方法'allTouches'在类'UIEvent'中定义,不可见”

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?

allTouches在 中定义,我尝试过这包括无效。 Xcode对这段代码似乎没有任何问题。有人对此有所了解吗?

1 个解决方案

#1


1  

Thats because allTouches is defined as property

那是因为allTouches被定义为属性

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

更高版本的iOS SDK使用属性而不是方法。并且,AppCode比Xcode具有更严格的类型检查。这就是Xcode静默编译和AppCode发出警告的原因

#1


1  

Thats because allTouches is defined as property

那是因为allTouches被定义为属性

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

更高版本的iOS SDK使用属性而不是方法。并且,AppCode比Xcode具有更严格的类型检查。这就是Xcode静默编译和AppCode发出警告的原因