I can't find this anywhere. I don't want to have to use the debugger everytime. How do I get print messages on the iphone.
Use the NSLog function:
NSLog(@"Your message here.");
// with parameters:
NSString * myParam = @"Some value";
NSLog(@"myParam:%@", myParam);
The messages get written to the console log. You can view them in the simulator by running Console.app or by switching XCode to the Debugger/Console view (XCode -> Run -> Console)
If you really want to do a popup alert (like the javascript alert()
function) you can do :
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message"
message:@"This is a sample"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
// open a alert with an OK and cancel button UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"My message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; [alert show]; [alert release];
Sample images:
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