2009-10-01 6 views

Répondre

41

Utilisez la fonction NSLog:

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

Les messages sont écrits dans le journal de la console. Vous pouvez les voir dans le simulateur en exécutant Console.app ou en passant XCode à la Debugger/vue Console (XCode -> Run -> Console)

Si vous voulez vraiment faire une alerte pop-up (comme la fonction javascript alert()) vous pouvez faire:

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

Pour votre information UIAlertView est maintenant dépréciés avec iOS 8. –

+1

exemple de remplacer '' UIAlertView' avec le nouveau UIAlertController 'on peut trouver ici: http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html – andi

+0

ou dans la documentation officielle: https: // développeur .apple.com/bibliothèque/ios/ documentation/UIKit/Référence/UIAlertController_class/index.html # // apple_ref/occ/cl/UIAlertController – andi

1

Recherchez UIAlertView avec Google ou Xcode Documentation Viewer.

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]; 

Images d'exemple:

enter image description here

+0

fonctionne comme un charme. UPVOTED! :) –

+0

Merci Tony Gil –

Questions connexes