A really basic question, I have recently started exploring Objective C and Trying to mess with one example code. However just for debugging purpose I want print value of NSString variable on console. How do I achieve this?
Basically I am a java developer, So I am looking something similar as...
String hello = "world!"; System.out.println(hello);
My variable in this foreign language(Obj-C) is...
NSString *hello = ...calling a method to return string...
Any hint will be appreciated!
Thank you
There is no format specifier to print boolean type using NSLog. One way to print boolean value is to convert it to a string. Another way to print boolean value is to cast it to integer, achieving a binary output (1=yes, 0=no).
In Swift with Xcode you can use either print() or NSLog() . print() just outputs your text.
In order to print logs, we use the NSLog method in Objective-C programming language which we have used right from the Hello World example. Now, when we compile and run the program, we will get the following result. 2013-09-16 00:32:50.888 demo[16669] Hello, World!
Pretty simple:
NSLog(@"Value of hello = %@", hello);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With