I'm trying to do an RSS Feed application for iOS and I'm trying to get the image URL from the description tag of the xml file (of the RSS Feed)
Here's my current code:
static NSMutableString *title;
static NSMutableString *linkPost;
static NSMutableString *descriptionPost;
static NSString *element;
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([element isEqualToString:@"title"]) {
[title appendString:string];
} else if ([element isEqualToString:@"link"]) {
[linkPost appendString:string];
} else if ([element isEqualToString:@"description"]) {
[descriptionPost appendString:string];
NSString *imgURL = descriptionPost;
imgURL = [imgURL substringFromIndex:[imgURL rangeOfString:@"src="].location+[@"src=" length]+1];
imgURL = [imgURL substringToIndex:[imgURL rangeOfString:@"alt="].location-2];
NSLog(@"log: imgURL = %@",imgURL);
}
}
My application crash and I get this in the crashlog:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFString substringFromIndex:]: Index 9223372036854775812 out of bounds; string length 1'
What does that mean? How can I fix this?