Lorsque j'essaie d'extraire une chaîne d'une chaîne plus grande, elle me donne une plage ou un index hors limites. Je pourrais oublier quelque chose de vraiment évident ici. Merci.Extraction d'une chaîne avec substringWithRange: donne "index out of bounds"
NSString *title = [TBXML textForElement:title1];
TBXMLElement * description1 = [TBXML childElementNamed:@"description" parentElement:item1];
NSString *description = [TBXML textForElement:description1];
NSMutableString *des1 = [NSMutableString stringWithString:description];
//search for <pre> tag for its location in the string
NSRange match;
NSRange match1;
match = [des1 rangeOfString: @"<pre>"];
match1 = [des1 rangeOfString: @"</pre>"];
NSLog(@"%i,%i",match.location,match1.location);
NSString *newDes = [des1 substringWithRange: NSMakeRange (match.location+5, match1.location-1)]; //<---This is the line causing the error
NSLog(@"title=%@",title);
NSLog(@"description=%@",newDes);
MISE À JOUR: La 2ème partie de la plage est une longueur, pas le point final. D'oh!
Vous devez mettre votre « solution » comme une réponse et l'accepter. – LucasTizma