objective-c – 在ObjC代码上使用LLVM 3.0抑制属性定义警告

前端之家收集整理的这篇文章主要介绍了objective-c – 在ObjC代码上使用LLVM 3.0抑制属性定义警告前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
由于 Xcode 4.2附带LLVM 3.0,我们终于可以使用自动合成.您可以通过在Apple LLVM编译器3.0 – 语言部分中将以下两个标志添加到其他C标志来打开它:

> -Xclang
> -fobjc-default-synthesize-properties

现在你可以摆脱你的@synthesize样板代码,如果你只想要属性合成的默认设置(我想我们已经使用了自动引用计数).

当我点击构建时,编译器警告我缺少@synthesize等语句,如下所示:

MyController.h:34:43: warning: property 'myProperty' requires method 'myProperty' to be defined - use @synthesize,@dynamic or provide a method implementation [3]
@property (strong,nonatomic) MyClass *myProperty;

我更喜欢无警告的构建,所以问题是:我怎样才能抑制这种警告,因为显然它们已经没有意义了.

解决方法

你确定-Xclang被传递给编译器

clang -x objective-c -Xclang -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o

没有显示任何警告

clang -x objective-c -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o

这是正确的方式,因为没有合成属性

这是我使用的TestClass.m:

#import <Foundation/Foundation.h>

@interface TestClass : NSObject

@property (nonatomic,strong) NSObject * test;

@end

@implementation TestClass

@end

猜你在找的Xcode相关文章