2009-10-01 30 views

Respuesta

41

utilizar la función NSLog:

NSLog(@"Your message here."); 
// with parameters: 
NSString * myParam = @"Some value"; 
NSLog(@"myParam:%@", myParam); 

Los mensajes se escriben en el registro de la consola. Puede verlos en el simulador mediante la ejecución de Console.app o cambiando XCode para el depurador/vista de la consola (XCode -> Run -> Console)

Si realmente quiere hacer una alerta emergente (como la función de JavaScript alert()) que puede hacer:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message" 
                message:@"This is a sample" 
               delegate:nil 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
+2

FYI UIAlertView ahora es obsoleto con IOS 8. –

+1

ejemplo de cómo sustituir '' nueva UIAlertView' con UIAlertController 'uno puede encuentre aquí: http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html – andi

+0

o en la documentación oficial: https: // developer .apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/index.html # // apple_ref/occ/cl/UIAlertController – andi

1

Busque UIAlertView con Google o el Visor de documentación de Xcode.

3
UIAlertView* alert; 
alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Much more info" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
[alert show]; 
[alert release]; 
4
// 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]; 

Imágenes de muestra:

enter image description here

+0

funciona como un encanto. ¡ACTUALIZADO! :) –

+0

Gracias Tony Gil –

Cuestiones relacionadas