简体   繁体   English

如何禁用Xcode编译器警告“属性访问结果未使用-吸气剂不应用于副作用”

[英]How to disable Xcode compiler warning “Property access result unused - getters should not be used for side effects”

我想知道如何禁用标题为:属性访问结果未使用的Xcode编译器警告-不应将吸气剂用于副作用

The best approach would probably be to cast to void , or assign to an unused variable ( T unused_var = property_access; ), and add a comment to the line stating why the return value is being discarded. 最好的方法可能是将其T unused_var = property_access;void ,或者将其分配给未使用的变量( T unused_var = property_access; ),并在行中添加注释,说明为什么丢弃返回值。 However... 然而...

Find the project setting for compiler flags and add: 找到编译器标志的项目设置,然后添加:

-Wno-unused-getter-return-value

This comes from Clang Options to Control Error and Warning Messages and Diagnostics Flags in Clang . 这来自Clang选项,用于控制Clang中的错误和警告消息以及诊断标志

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wno-unused-getter-return-value" // or whatever

-(void)yourMethodHere{
// generate warning
}

#pragma clang diagnostic pop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “未使用属性访问结果 - 不应将getter用于副作用”警告 - “Property access result unused - getters should not be used for side effects” warning Xcode警告“未使用属性访问结果 - 不应将getter用于副作用” - Xcode warning “Property access results unused - getters should not be used for side effects” 向LocatNotification错误添加变量是未使用属性访问结果-不应将吸气剂用于副作用 - Adding variable to LocatNotification error is Property access result unused - getters should not be used for side effects Objective-C:吸气剂不应用于副作用编译器警告 - Objective-C: Getters should not be used for side effects compiler warning 正确清理物体“吸气剂不应用于副作用” - Clearing an object properly “getters should not be used for side effects” 属性访问结果未使用 - Property access result unused xCode:尝试创建密钥窗口时,“未使用属性访问结果” - xCode: “Property access result unused” when trying to make key window Xcode 4警告“ NSURLConnection的表达结果未使用” - Xcode 4 warning "Expression result unused” for NSURLConnection XCode警告“表达式结果未使用”的数学陈述 - XCode Warning “Expression Result Unused” for mathematical statement 如何强制“表达结果未使用”警告发生 - How to force “Expression result unused” warning to happen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM