NSLog(@"<#chaine#>"); NSLog(@"<#chaine#> = %@", <#chaine#>); NSLog(@"<#entier#> = %d", <#entier#>); NSLog(@"<#entier4car#> = %04d", <#entier#>); NSLog(@"<#réel#> = %f", <#réel#>); NSLog(@"<#réel2.2#> = %2.2f", <#réel#>);
NSString * <#uneChaine#> = [[NSString alloc] initWithFormat:@"<#Je suis %@, j'ai %d an(s) et mon poids est de %2.2f kg#>", <#uneChaine#>, <#unEntier#>, <#unRéel#>];
NSString * <#uneChaine#> = [NSString stringWithFormat:@"<#Je suis %@, j'ai %d an(s) et mon poids est de %2.2f kg#>", <#uneChaine#>, <#unEntier#>, <#unRéel#>];
NSString * <#uneChaine#> = [[NSString alloc]initWithFormat:@"%@%@%@", <#chaine1#>, <#chaine2#>, <#chaine3#>];
tableauDesVideos = [[NSArray alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Listes des videos" ofType:@"plist"]];
self.imageView.image = [UIImage imageNamed:@"fichier.png"];
/ Pour avoir accès à .layer
#import <QuartzCore/QuartzCore.h>
@interface ViewController () {
  UIImage * _imageFinale; // Pour stocker une copie de la scène sous forme d’image
}
@end
-(void) sauvegarder{
  // Description : méthode servant à capturer l’écran et au besoin,
  // en faire une sauvegarde dans l’album photos.
  // 1 - Préparer un contexte de dessin à partir de la taille de la scène
  UIGraphicsBeginImageContext(self.view.bounds.size);
  // 2 – Dessiner à partir du claque par défaut de la scène
  [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
  // 3 – Stocker le résultat dans notre objet local
  _imageFinale = UIGraphicsGetImageFromCurrentImageContext();
  // 5 – Fermer le contexte de dessin
  UIGraphicsEndImageContext();
  // 6 – Facultatif - Stocker une copie de la capture d’écran dans l’album photos
  UIImageWriteToSavedPhotosAlbum(_imageFinale, nil, nil, nil );
}
#import <Social/Social.h>
- (IBAction)posterSurTwitter:(id)sender {
 // Les étapes pour utiliser ‘twitter’
 // 1 - Tester si le service et les informations de connexion sont dispo
 if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
 {
 // 2 - Créer un feuille pour le 'post'
 SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
 // 3 - Composer le message
 [tweetSheet setInitialText:@"TIM.Magazine - via labo app iOS, Production sur support 2013. #CSTJ"];
 // 4 - Ajouter une image - facultatif
 // [tweetSheet addImage:_imageFinale];
 // 5 - Ajouter un lien - facultatif
 // [tweetSheet addURL:[NSURL URLWithString:@"http://tim.cstj.qc.ca"]];
 // 6 - Présenter la fenêtre de confirmation à l'utilisateur
 [self presentViewController: tweetSheet animated: YES completion: nil];
 } // if twitter disponible ...
}
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
 SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
 [controller setInitialText:@"Le texte à poster …"];
 // [controller addURL:[NSURL URLWithString:@"http://tim.cstj.qc.ca"]]; // au besoin
 // [controller addImage: uneImage]; // au besoin
 [self presentViewController:controller animated:YES completion:Nil];
 }
[self dismissViewControllerAnimated:YES completion:nil];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier: // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls) - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
#import "CelluleVideo.h"
// tableView: cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CelluleVideo * celluleCourante = [tableView dequeueReusableCellWithIdentifier:@"modeleCellule" forIndexPath:indexPath];
    celluleCourante.videoTitre.text = tableauDesVideos[indexPath.row][@"titre"];
    celluleCourante.videoImage.image = [UIImage imageNamed:tableauDesVideos[indexPath.row][@"pochette"]];
    celluleCourante.videoAnnee.text = tableauDesVideos[indexPath.row][@"annee"];
    celluleCourante.videoCote.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-star-rating.png", tableauDesVideos[indexPath.row][@"cote"]]];
    return celluleCourante;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section; // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath; - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
NSMutableArray * images = [NSMutableArray new]; for (int i=0; i<=NB_IMAGE;i++) [images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"explosion-%03d.png",i]]]; // Au besoin, image auto animée // self.image = [UIImage animatedImageNamed:nomFichier duration:10]; self.animationImages = images; self.animationRepeatCount = 1; self.animationDuration = DUREE_ANIMATION;
celluleCourante.filmImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlImage]]];
// ========================================================================
- (NSDictionary *)convertirJSON:(NSString *) adresseURL
// ========================================================================
{
    NSDictionary * structureJSONConvertie;
    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:adresseURL]];
    NSError *error;
    structureJSONConvertie = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    // Attention, il faudrait tester 'error'
    return structureJSONConvertie;
}   // *** fin - convertirJSON
// Lancée automatiquement avant une transition 'segue'
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    // Pointer sur la scène de destination
    VCDetailVideoCourante * vcDetail = [segue destinationViewController];
    // sender -> pointe sur la cellule sélectionnée
    int selectionCourante = [[self.TViewVideos indexPathForCell:sender] row];
    // Envoyer les informations de la sélection courante
    vcDetail.videoInfo = tableauDesVideos[selectionCourante];
}
[self performSelector:@selector(transitionVersListeVideos) withObject:self afterDelay:0.5];
//  ViewController.m
#import "ViewController.h"
#define INTERVALLE_TIMER 1  // en secondes
@interface ViewController () {
    NSTimer * jeSuisUnTimer;
    int     i;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    i = 0;
    jeSuisUnTimer = [NSTimer scheduledTimerWithTimeInterval:
        INTERVALLE_TIMER                        // en secondes  ( 0.x est valide)
        target:self                             // L'objet qui va recevoir le message
        selector:@selector(uneMethode)          // Méthode à exécuter à 'INTERVALLE_TIMER'
        userInfo:nil                            // Un objet qui sert à passer des données
        repeats:YES                             // YES = toujours, NO = 1 fois
        ];
}
- (void) uneMethode{
    NSLog(@"Je suis dans -> uneMethode %i fois", ++i);
    if ( i == 10){
        [jeSuisUnTimer invalidate];  //Arrêter le timer
    }
}
@end
@interface ViewController () <UIAlertViewDelegate>
{
   _unAlert = [[UIAlertView alloc]
                initWithTitle:@"Attention"
                message:@"Ceci est une 'Alerte bleue'!"
                delegate:self
                cancelButtonTitle:@"Non"
                otherButtonTitles:@"Oui", @"Peut-être", nil
                ];
    [_unAlert show];
    NSLog(@"[_unAlert show] lance une opération non bloquante");
}
// Méthode délégation de alertView
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    NSLog(@"Bouton: %i, sélectionné.", buttonIndex);
}
uneScene = [[[NSBundle mainBundle] loadNibNamed:@"nomFichierXIB" owner:self options:nil] objectAtIndex:0];
// Animer la propriété alpha d'un UIView
[UIView     animateWithDuration: 2.5
                              delay: 0.0
                            options: UIViewAnimationOptionCurveEaseIn
                         animations: ^{
                             NSLog(@"Démarrage de l'animation...");
                             self.UIUneLumiere.alpha = !self.UIUneLumiere.alpha;
                         }
                         completion:^(BOOL finished) {
                             NSLog(@"Animation terminée!");
                         }
     ];
CGRect personnage = [[lePersonnage.layer presentationLayer]frame];
CGRect sousZone = CGRectInset(personnage, personnage.size.width/2,personnage.size.height/2 );
if (CGRectIntersectsRect(sousZone, unObjet.frame))
{
  NSLog(@"Il y a eu collision entre le personnage et %@", unObjet.class);
}
[self.view insertSubview:uneView atIndex:[self.view.subviews count]-1];
info = unDictionnaire[@"tableauElements"][indiceElement][@"nomChamp"];
NSArray * unTableau1 = [NSArray arrayWithObjects:@"Je",@"suis",@"fou", @"de TIM",nil]; // ou bien NSArray * unTableau2 = @[@"Je",@"suis",@"fou", @"de TIM"];
for(NSString * uneChaine in unTableau) {
   chaineResultat = [NSString stringWithFormat:@"%@ %@",chaineResultat,uneChaine];
}
NSDictionary * unDictionnaire = [[NSDictionary alloc]
                                     initWithObjectsAndKeys:@"Montréal", @"mtl",
                                     @"Québec", @"qc",
                                     @"Saint-Jérôme", @"stj"
                                     ,nil];
// Ou bien
NSDictionary * unDictionnaire2 = @{@"mtl": @"Montréal", @"qc": @"Québec", @"stj": @"Saint-Jérôme" };
//Pour parcourir les éléments d'un dictionnaire
for(NSString * key in unDictionnaire){
   NSLog(@"clé: %@, contenu: %@", key, unDictionnaire[key]);
}
NSDate * presentement = [NSDate date]; NSDateFormatter *unFormateurDeDate = [[NSDateFormatter alloc] init]; [unFormateurDeDate setDateFormat:@"'Nous sommes 'EEEE' et il est 'hh:mm:ss"]; NSString *heuresMinutesSecondes = [unFormateurDeDate stringFromDate:presentement]; self.nousSommes.text = heuresMinutesSecondes;
- (void)viewDidLoad
{
    [super viewDidLoad];
    //  Création d'un bouton par programmation
    UIButton * unBouton;
    unBouton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    unBouton.frame = CGRectMake(1, 1, 100, 30);
    [unBouton setTitle:@"Continuer" forState:UIControlStateNormal];
    [unBouton setAlpha:0.9];
    [unBouton addTarget:self action:@selector(boutonAppuye) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:unBouton];
}
- (void)boutonAppuye {
    UIAlertView * myAlert;
    myAlert = [[UIAlertView alloc]
               initWithTitle:@"Bouton appuyé!"
               message:@"Continuer?"
               delegate:self
               cancelButtonTitle:@"Non"
               otherButtonTitles:@"Oui", nil
               ];
    [myAlert show];
}