2

How to mask an unwanted "Dead Store" warning in XCode? That is I have this code for which I don't think it's an issue, so if this is the case I don't want to keep seeing the warning...(welcome for feedback however)

Code is here:

// Position and Size Labels in Cell
CGFloat currVertPos = 0; // Maintain lowest position, i.e. starting vertical point for next cell

// Set Position & Get back next veritical position to use
currVertPos = [self resizeLabel:_mainLabel atVertPos:currVertPos];
    currVertPos = [self resizeLabel:_mainLabel2 atVertPos:currVertPos];
    currVertPos = [self resizeLabel:_mainLabel3 atVertPos:currVertPos];
currVertPos = [self resizeLabel:self.secondLabel atVertPos:currVertPos];  // WARNING OCCURS HERE 

Warning Detail = Value stored "currVertPos" at is never read.

So it's true that for the last line the "currVertPos" isn't needed, but does it really matter, and if not how can I silence the warning?

Greg
  • 34,042
  • 79
  • 253
  • 454

2 Answers2

7

No, the warning doesn't matter; you can eliminate it simply by not doing the store. Delete the currVertPos = from the last line and there will be nothing to warn you about.

Gabe
  • 84,912
  • 12
  • 139
  • 238
7

One other alternative is to use:

#pragma unused(currVertPos)

Source: https://stackoverflow.com/questions/194666/is-there-a-way-to-suppress-warnings-in-xcode

Community
  • 1
  • 1
jorgecarreira
  • 301
  • 2
  • 6
  • This worked for me when the compiler got confused because the variables were used in an if statement. #pragma unused(showHideButtonX) #pragma unused(showHideButtonY) if ( DISPLAY_SHOWHIDE_BUTTON ) { CGRect showHideFrame = CGRectMake(showHideButtonX, showHideButtonY, buttonsSize, buttonsSize); – JScarry Feb 10 '13 at 16:09