1

I converted a std::string to NSString* by :

NSString *BufferString = [[NSString alloc] initWithCString:allBufferString.c_str()
                                                    encoding:[NSString defaultCStringEncoding]];

The code cout<<allBufferString; shows the whole string in Log. But NSLog(@"%@ ",BufferString) doesn't show all the data instead ends with 0.061523 -0.03<...> in the log .

So two questions:

  1. If I send the NSString as a JSON string. Will all data be there?

  2. How can I print all the data in the NSLog ?

Shivansh Jagga
  • 1,541
  • 1
  • 15
  • 24
  • 1. Add the logs to your Q, in case of that they are too long, shorten it in the middle. 2. What is the result of `[bufferString length]`? It is okay? 3. What happens, if you send the data? Did you try it? If not, why? 4. Why do you want to log all data? `NSLog()` is not a printing service, but a logging service. 5. What do you get with `po bufferString`? 6. Respect the Objective-C naming rules. – Amin Negm-Awad Jul 06 '17 at 16:28
  • Ya. I wasted a week because of the NSLog problem. NSLog is now truncated by XCode for god knows why. NSLog is not reliable to debug long data anymore. People are making custom logging function due to this. Thank you Apple. – GeneCode Jul 07 '17 at 02:14
  • 1
    @Amin Negm - It was showing it as `` – Shivansh Jagga Jul 07 '17 at 07:44
  • @GeneCode I know, I know: `NSLog()` is not a debugging tool. – Amin Negm-Awad Jul 07 '17 at 08:29
  • @AminNegm-Awad funny you say that since in Apple Technical Note itself they listed NSLog as one of the debug tool. https://developer.apple.com/library/content/technotes/tn2347/_index.html#//apple_ref/doc/uid/DTS40014516-CH1-TNTAGN1 – GeneCode Jul 07 '17 at 08:36

1 Answers1

1

It is Xcode bug (or feature). You can print logs as in this post

#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
toma
  • 1,471
  • 12
  • 20