Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print NSString Argument using NSLog

Tags:

-(void) postToDB:(NSString*) msg{     //print msg     NSString *myphp = @"/Applications/MAMP/htdocs/databases/test.php";     NSURL *url = [NSURL URLWithString:myphp];     ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];     [request setPostValue:msg forKey:@"message"]; } 

In the above method, how can I print 'msg' using NSLog?

Many thanks

like image 610
user559142 Avatar asked Jul 06 '11 13:07

user559142


People also ask

How do you print a string value in Objective C?

You can use %@ for all objects including NSString. This will in turn call the objects description method and print the appropriate string.

How do I print a boolean in Objective C?

%@ is for objects. BOOL is not an object. You should use %d . It will print out 0 for FALSE/NO and 1 for TRUE/YES.

How do I print something in Objective C?

In C Language (Command Line Tool) Works with Objective C, too: printf("Hello World"); In Objective C: NSLog(@"Hello, World!");

What is NSString?

A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.


1 Answers

NSLog(@"%@",msg); its of type NSString.

like image 145
Praveen S Avatar answered Sep 17 '22 09:09

Praveen S