I have a problem with StringWithFormat not working. The debugger says the returned string is not an NSString (and it is not null), thus my calls with the supposed NSString will not match a method selector, and my app crashes.
I am testing on XCode 4.5 iOS 6 settings (old project, no sub-projects).
This code will return something that is not an NSString:
[NSString stringWithFormat:@"\nTest to %@ (%@)\n", target, ipString]
If I insert a space as the first character in the format string, then the result is an NSString, i.e. the following works:
[NSString stringWithFormat:@"\nTest to %@ (%@)\n", target, ipString]
This code block also does not work. It returns something not an NSString. What am I doing wrong here ?
int TTL = 1;
NSString *ttl = [NSString stringWithFormat:@" \n# %d", TTL] ;
TTL++;
[self textToParent: ttl]; // Program crashes here. Debugger show ttl not NSString.
TTL--;
The error message is ttl = (__NSCFString *) 0xwhatever @<variable is not NSString>
Try changing the first two lines to..