Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iphone popup alert message

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.

like image 657
DevDevDev Avatar asked Oct 01 '09 02:10

DevDevDev


2 Answers

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];
like image 173
Jason Jenkins Avatar answered Oct 05 '22 14:10

Jason Jenkins


// 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:

enter image description here

like image 28
Adrian Pirvulescu Avatar answered Oct 05 '22 13:10

Adrian Pirvulescu