objectivec-如何清除不匹配的参数:nullable和FooType是AppCode中不兼容的警告



这可能是一个AppCode问题,因为Xcode没有标记这个特定的场景。

我在AppCode:的不同地方看到了这个错误

Parameter type mismatch: Types 'nullable' and 'FooType' are not compatible

其中FooType可以是任何类型。

以下是一个演示问题的电话:

[self.view addConstraint:[NSLayoutConstraint constraintWithItem:spinnerBackgroundView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:0]];

其中toItem值将标记有警告。

查看API,toItem参数可以为空:

+(instancetype)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(nullable id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c;

这是由我调用API的方式引起的吗?或者这是AppCode中的一个小故障(除了"切换到getter模式"之外,它没有提供任何建议,这没有什么区别。)

这几乎肯定不是AppCode的错误,但如果没有看到FooType的接口声明,就很难说是肯定的。它很可能是一个放错地方的"nullable"属性,编译器将其解释为类型定义。

最新更新