Just a simple question on NSStrings, I have a piece of code that assigns a value to a string, depending on what is found it is either assigned a value by substringToIndex or the constant string @"0.00", is it okay to use
// Save if value found, otherwise set to 0.00
if (parsedCharacters == nil || [parsedCharacters isEqualToString:@""])
self.currentDiscountedPrice = @"0.00";
else
{
// Truncate extra digits from string to 2 decimal places (find full stop, save 2 places after it)
NSRange fullStopRange = [parsedCharacters rangeOfString:@"."];
self.currentDiscountedPrice = [parsedCharacters substringToIndex:(fullStopRange.location + 3)];
}
for the assignment since it will release the old value & retain the new value?
There is no way of knowing whether the var was assigned the constant string or the substringToIndex returned value in the previous iteration but I was told calling retain & release on constant strings is harmless, is this true?