-(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
You can use %@ for all objects including NSString. This will in turn call the objects description method and print the appropriate string.
%@ 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.
In C Language (Command Line Tool) Works with Objective C, too: printf("Hello World"); In Objective C: NSLog(@"Hello, World!");
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
NSLog(@"%@",msg);
its of type NSString.
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