简体   繁体   中英

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. 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 .

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

-(void)yourMethodHere{
// generate warning
}

#pragma clang diagnostic pop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM