When NSString Doesn’t Create A String With A String

If one goes to the NSString documentation, one quickly realizes that there is a very nice convenience method,

+ (id)stringWithString:(NSString *)aString


    The string from which to copy characters. This value must not be nil.

Raises an NSInvalidArgumentException if aString is nil.

Return Value
A string created by copying the characters from aString.

One would be forgiven for not noticing that little note that is supposed to catch your attention by having the title, Important. And it is important. Because, let’s say that you are trying to tell your iOS user how much an app feature upgrade cost,

NSString *titleString1 = [NSString stringWithString:@"Upgrade Flush'em for "];
NSString *titleString2 = [NSString stringWithString:[PFIAPManager sharedManager].upgradePrice];
NSString *titleString3 = [titleString1 stringByAppendingString:titleString2];
NSString *titleMessage = [titleString3 stringByAppendingString:@"?"];