2017-04-15 1 views
0

Comment obtenir la date et le titre et la description seule de ce résultat d'analyse syntaxique:Comment obtenir la date et le titre et la description seule de ce résultat d'analyse syntaxique

title = "Inter-views 29/03/2017 random description here (its in arabic); 
title = " \U0627\U062e\U0628\U0627\U0631 \U0627\U0644\U0635\U0628\U0627\U062d 14/04/2017"; 

C'est l'analyse syntaxique de même api mais différent (didSelectRowAtIndexPath). J'utilise actuellement ce code mais comme je l'ai indiqué, l'analyse est différente. Donc je ne peux pas utiliser la logique statique.

code:

NSString *myString = [item objectForKey:@"title"]; 

    NSMutableArray *myArray = [[NSMutableArray alloc] 
    initWithArray:[myString componentsSeparatedByCharactersInSet: 
    [NSCharacterSet characterSetWithCharactersInString:@" "]]]; 

     NSString *Category = @""; 
     if(myArray.count>=1){ 
      Category = [myArray objectAtIndex:0]; 
      [myArray removeObjectAtIndex:0]; 
     } 
     NSString *Date = @""; 
     if(myArray.count>=1) { 
      Date = [myArray objectAtIndex:0]; 
      [myArray removeObjectAtIndex:0]; 
     } 
     cell.dateLabel.text = [[NSString alloc] initWithFormat:@"%@", [Utils dateTransform:[Date stringByReplacingOccurrencesOfString:@" " withString:@""] FromFormat:@"dd-MM-yyyy" ToFormat:@"dd-MMMM-yyyy"]]; 
     NSString *Title = @""; 
     for (NSString *word in myArray) { 
      Title = [Title stringByAppendingString:word]; 
      Title = [Title stringByAppendingString:@" "]; 
     } 
     cell.titleAndDescLabel.text =[NSString stringWithFormat:@"%@ %@", Category,Title]; 
+0

comment vous obtenez vos données? du webservice? Pouvez-vous s'il vous plaît me donner la réponse si vous obtenez vos données du serveur. –

+0

@DishantRajput QUE la réponse, mais comme je l'ai dit est différent des autres : id = 3502; image = ""; isYoutube = 1; link = "https://youtu.be/a_AnoV3y1EM"; title = « Inter-vues 29/03/2017 \ U0645 \ U0639 \ U0623 \ U0648 \ U0644 \ U0648 \ U0632 \ U064a \ U0631 \ U062f \ U0 } et c'est une autre réponse: id = 3432; image = ""; isYoutube = 1; link = "https://youtu.be/bSds01Ew6ns"; title = "Entretiens 22/03/2017"; } – Baloomba

+0

Veuillez cocher ma réponse. avoir à utiliser pour la boucle pour obtenir votre valeur un par un.Si cela fonctionne s'il vous plaît faites le moi savoir. –

Répondre

0

Votre devez utiliser pour la boucle pour obtenir la valeur

for (NSInteger i=0; i<[[jsonObject objectForKey:@"yourMainKey"]count]; i++) 
      { 

NSString *strname =[[[jsonObject objectForKey:@"yourMainKey"]objectAtIndex:i]objectForKey:@"date"]; 

       NSLog(@"strname==%@, strname); 


NSString *str title =[[[jsonObject objectForKey:@"yourMainKey"]objectAtIndex:i]objectForKey:@"title"]; 

       NSLog(@"strtitle ==%@, strtitle); 

NSString *str description =[[[jsonObject objectForKey:@"yourMainKey"]objectAtIndex:i]objectForKey:@"description"]; 

       NSLog(@"description ==%@, description); 



      }