Question

I'm using Xcode 4.6. My app is working on the device and the simulator, but I get a warning when building:

"Format string is not a string literal (potentially insecure)"

from this code

[sArray addObject:[NSString stringWithFormat:subCatName]];

l.text= [spacing stringByAppendingFormat:[mArray objectAtIndex:section]];

Why, and how do I fix it?

Was it helpful?

Solution

Since you are not actually formatting a string, do this:

[sArray addObject:subCatName];

l.text= [spacing stringByAppendingString:[mArray objectAtIndex:section]];

For some reason, NSString stringWithFormat: is one of the most overused methods I see on SO. It should only be used when you are actually formatting a string with one or more variables being placed into the final string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top