より大きな文字列から文字列を抽出しようとすると、範囲外またはインデックスの範囲外エラーが発生します。私はここで本当に明白な何かを見落としているかもしれません。ありがとう。
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);
更新:範囲の2番目の部分は長さであり、端点ではありません。D'oh!