objective c - How can I get rid of an "unused variable" warning in Xcode? -


I understand that unused variables are due to warnings. I do not want to suppress them normally because they are incredibly useful in most cases. However, consider the following (genetic) code.

  NSError * Error = zero; BOOL saved = [moc save: & amp; Error]; NSAssert1 (saved, @ "Dude !! 1!% @ !!!", error);   

Xcode reports that saved is an unused variable, when it is not at all. I suspect this because NSAssert1 is a macro NS_BLOCK_ASSERTIONS macro is defined not , hence the claim of objective C is definitely enabled.

Although it does not hurt anything, I make it unnecessary and annoying, and I want to suppress it, but I am not sure how to do it. Assigning the variable to yourself will get rid of the compiler warning, but I would like to do this in the "right way" if such a thing exists. I am unsure that it is still supported in the new LLVM compiler, but in GCC an "unused" The attribute that you can use to suppress the warning:

  BOOL saved __detect __ ((unused)) [[save mock: & amp; Error]; Alternatively (if the LLVM does not support above), you can split the variable declaration into a separate row, guaranteeing that the "matros" macro expands:  
  BOOL saved = no; Saved = [save mok: & amp; Error];    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -