views:

360

answers:

3

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.

+3  A: 

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 test"
                                                 delegate:nil
                                        cancelButtonTitle:@"OK" 
                                        otherButtonTitles:nil];
 [alert show];
 [alert release];
Jason Jenkins
A: 

Look for UIAlertView with either Google or the Xcode Documentation Viewer.

jbrennan
+1  A: 
UIAlertView* alert;
alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Much more info" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
Rob