在 ObjC 代码上使用 LLVM 3.0 抑制属性定义警告
由于 Xcode 4.2 附带了 LLVM 3.0,我们终于能够使用自动合成了。您可以通过将以下两个标志添加到 Apple LLVM compiler 3.0 - Language
部分中的 Other C Flags
来打开它:
-Xclang
- < code>-fobjc-default-synthesize-properties
现在,如果您只想使用属性合成的默认设置(我想我们已经使用自动引用计数)。
当我点击构建时,编译器会警告我缺少 @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;
我更喜欢无警告构建,因此问题是:我怎样才能抑制这种警告,因为显然它们不再有意义了。
Since Xcode 4.2 comes with LLVM 3.0 we're finally able to use automatic synthesizeation. You can turn it on by adding the following two flags to your Other C Flags
in the Apple LLVM compiler 3.0 - Language
section:
-Xclang
-fobjc-default-synthesize-properties
Now you can get rid of your @synthesize
boiler plate code if you just want the default settings for your property synthesizeation (I guess we already use automatic reference counting).
When I hit build, the compiler warns me about missing @synthesize
etc. statements, like so:
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;
I prefer a warning-free build, so the question is: How can I suppress this kind of warnings because obviously they don't make sense anymore.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定 -Xclang 传递给编译器
不会显示任何警告,而
这样做是正确的,因为没有合成任何属性
这是我使用的 TestClass.m:
Are you sure -Xclang is passed to the compiler
does not show any warnings while
does which is by the way correct since no properties are synthesized
Here is the TestClass.m I used:
好的,我设法使用这些 C 标志来抑制该警告:
不幸的是,getters/setters 不会被合成(...事实上我的应用程序崩溃了...)
Ok, I managed to suppress that warning using these C flags:
Unfortunately, getters/setters don't get synthesized (...and in fact my app crashes...)