Hi there, I'm trying to run through some htmlcode to fetch which tags are in
Basicly I'm looking for form input tags and I want to get the ID and/or Class and/or default value and all. And then I will save them to an tableview.
For now I got this:
The first few will go fine. and eventually ending up with an crash
-[__NSCFString substringWithRange:]: Range {23491, 10} out of bounds; string length 23498
Why does this happen, and how could I fix it ?
Basicly I'm looking for form input tags and I want to get the ID and/or Class and/or default value and all. And then I will save them to an tableview.
For now I got this:
Code:
long length = [curPageSource length];
BOOL openCode = NO;
long openCodeLoc = 0;
BOOL closeCode = NO;
long closeCodeLoc = 0;
for(int chr = 0; chr < length; chr++) {
char curCharacter = [curPageSource characterAtIndex: chr];
if(!openCode && curCharacter == '<') {
NSString *checkCode = [curPageSource substringWithRange:NSMakeRange(chr, 10)];
if([checkCode rangeOfString:@"<input"].location != NSNotFound) {
openCode = YES;
openCodeLoc = chr;
NSLog(@"Found input");
}
}
if(openCode && curCharacter == '>') {
closeCode = YES;
closeCodeLoc = chr;
}
if(openCode && closeCode) {
NSLog(@"Going through the found code...");
openCodeLoc = 0;
closeCodeLoc = 0;
openCode = NO;
closeCode = NO;
}
}
The first few will go fine. and eventually ending up with an crash
-[__NSCFString substringWithRange:]: Range {23491, 10} out of bounds; string length 23498
Why does this happen, and how could I fix it ?