Xcode 4.3 在 current 中存在未声明的方法时不会发出警告
@implementation
,这是一个很棒的新特性。但是,在 Xcode 4.2 上使用我的项目时,这在某些情况下会导致问题。
如何重新启用未声明方法的警告?
例如:
@interface MashTun : NSObject
- (void)foo;
@end
@implementation MashTun
- (void)foo {
CGRect rect = [self smallRect];
NSLog(@"My Small Rect: %@", NSStringFromCGRect(rect));
}
- (CGRect)smallRect {
return CGRectMake(0, 0, 100, 100);
}
@end
在 Xcode 4.2 中,这会失败:
warning: instance method '-smallRect' not found (return type defaults to 'id')
error: initializing 'CGRect' (aka 'struct CGRect') with an expression of incompatible type 'id'
我完全理解 Xcode 4.2 中的警告和错误,因为它不允许在当前@implementation
范围内搜索方法。(修复很简单:要么将方法放在smallRect
方法之上,要么在类别或标题中foo
声明方法。)smallRect
但是,如何在 Xcode 4.3 中打开警告以捕获此错误,然后再将其传递给运行 4.2 的同事?