0

After analyzing my project, I seem to be getting the following warning:

Value stored to 'currentWordRange' during its initialization is never read

for the following lines in viewDidLoad:

if (self.wordToAdd && self.wordToAdd != (id)[NSNull null] && self.wordToAdd.length != 0 ) {
    NSRange currentWordRange = NSMakeRange(0, 0);
            currentWordRange = [checker rangeOfMisspelledWordInString:self.wordToAdd range:NSMakeRange(0, self.wordToAdd.length) startingAt:0 wrap:NO language:@"en_US"];
}

Is it that I'm not creating my NSRange correctly?

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
KingPolygon
  • 4,753
  • 7
  • 43
  • 72
  • Your first line is useless, since you just redefine currentWordRange in the next line, but the error is saying that you never use currentWordRange after you create it. – rdelmar Dec 12 '14 at 23:59

1 Answers1

1

No, it's nothing like that. You don't need to call NSMakeRange on a range before using it. It's a scalar type, not an object.

You're initializing a range with 0,0, replacing it with a new value a line later, and then forgetting about the range value as soon as your code leaves the braces of your if statement.

Your code won't fail or anything, but the value of currentWordRange is ignored. It's like writing a letter and then throwing it away without mailing it. A harmless waste of time.

Duncan C
  • 128,072
  • 22
  • 173
  • 272