0

I have a variable passed to a method using type NSString * that is actually showing up in the debugger:

po [myString class]
__NSCFString

If I po myString from a debugger prompt, I can see the value of the string. However, if I NSLog it, it does not print. From what I understand, NSString and __NSCFString are toll-free bridged, so one can be used like the other. So why is it not printing from an NSLog statement? Is there something I can do to force it?

The string is initialized thus:

NSString *result = [NSString stringWithUTF8String:(const char *)content];

This result variable is passed from one object to another using NSString * arguments. The NSLog statement looks like this:

NSLog(@"Did not find \n%@ %@\n%@",key, name, myString);

Output of this includes the values of key and name but not myString. If I set a breakpoint on the next line, I can query the value of myString using the po command.

Victor Engel
  • 2,037
  • 2
  • 25
  • 46
  • Update your question with your `NSLog` as well as the code that declares and assigns a value to the string. – rmaddy Apr 22 '16 at 21:09
  • Maybe __NSCFString doesn't implement -description but NSString does? – Victor Engel Apr 22 '16 at 21:31
  • Maybe this is a clue: if I add `NSString *x = [NSString stringWithFormat:@"Did not find \n%@ %@ %@",key, name, myString];` followed by `NSLog(@"%@",x);` then what I get is the values of `key` and `name` followed by a bunch of white space. – Victor Engel Apr 22 '16 at 21:52
  • Was this string, by chance, initialized by deserializing JSON via Apple's NSJSONSerialization? If so, I'm having the same issue. The good news is it otherwise acts the same. – David Hodge Feb 12 '17 at 03:20
  • It's been so long, I cannot recall. – Victor Engel Feb 13 '17 at 04:55

0 Answers0