How can I use NSLog inside a CPP file?
Hi friends!
How can I use NSLog inside a CPP file? I mean, should I include or import any file? and How I send to it a string?
Thanks a lot for your help.
How can I use NSLog inside a CPP file? I mean, should I include or import any file? and How I send to it a string?
Thanks a lot for your help.
By renaming to file to .mm, or using printf/cout instead. NSLog requires NSString, which requires an Objective-C compilation mode. The .mm extension allows you to compile as Objective-C++.
ThemsAllTook Wrote:By renaming to file to .mm, or using printf/cout instead. NSLog requires NSString, which requires an Objective-C compilation mode. The .mm extension allows you to compile as Objective-C++.
Thanks! I didn't know printf could work. Thanks a lot.
Edit: It seems only works on the simulator, but not when I launch the app on my iPhone. Do you all have the same problem? Any idea?
Thanks.
riruilo Wrote:Edit: It seems only works on the simulator, but not when I launch the app on my iPhone. Do you all have the same problem? Any idea?
Thanks.
In what way does it not work on the iPhone?
Are you getting build errors, or are you not getting console output in Xcode as you expect?
Are you building for distribution or debug?
Are you launching the app from the iPhone, or launching the app from Xcode?
[edit] I ask because the only way I ever see console output from the iPhone in Xcode is build for debug and launch from Xcode. Otherwise you have to look at the console tab in the organizer to see the output.
AnotherJake Wrote:In what way does it not work on the iPhone?
Are you getting build errors, or are you not getting console output in Xcode as you expect?
Are you building for distribution or debug?
Are you launching the app from the iPhone, or launching the app from Xcode?
[edit] I ask because the only way I ever see console output from the iPhone in Xcode is build for debug and launch from Xcode. Otherwise you have to look at the console tab in the organizer to see the output.
OK. Now it is working perfectly, thanks a lot!

