The code works correctly, but I am getting the warning “Argument in message expression is an initialized value” for this piece of code:
NSString *quality;
switch(theItem.quality) {
case 1:
quality = @"UNDEF, Set it up!";
break;
case 2:
quality = @"G, (Good)";
break;
case 3:
quality = @"VG, (Very Good)";
break;
case 4:
quality = @"F, (Fine)";
break;
case 5:
quality = @"VF, (Very Fine)";
break;
case 6:
quality = @"XF, (Extra Fine)";
break;
case 7:
quality = @"UNC, (Uncirculated)";
break;
case 8:
quality = @"PROOF, (Proof)";
break;
}
str = [NSString stringWithFormat:@"%@", quality];
Is it some issue or it’s nothing and I can ignore it?
Also, is it ok to initialize NSString this way -> NSString *quality;?
Did you mean “uninitialized value”? If none of your case statements match, the
qualityvariable will end up being uninitialized, which will likely crash once it gets to the+stringWithFormat:. You can either initializequalitywith a default value (perhapsnil), or you can provide adefaultstatement in yourswitchthat initializes it.