I´m working on an app that displays 6 pictures from a website. These pictures change over time so I extracted the sourcecode of said website and managed to pull the first of the 6 pictures with this code:
NSError *error = nil;
NSString *deviantStringPopular;
deviantStringPopular = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://browse.deviantart.com/?order=24"]
encoding:NSISOLatin1StringEncoding
error:&error];
NSString *popularContent;
NSRange popularURLRange1 = [deviantStringPopular rangeOfString:@"super_img=\""];
NSRange popularURLRange2 = [deviantStringPopular rangeOfString:@"\" super_w"];
int lengt = popularURLRange2.location - popularURLRange1.location - popularURLRange1.length;
int location = popularURLRange1.location + popularURLRange1.length;
NSRange endRange;
endRange.location = location;
endRange.length = lengt;
popularContent = [deviantStringPopular substringWithRange:endRange];
NSLog(@"%@", popularContent);
The problem is, the other 5 images' URLs are between the same substrings as the first one. So is it possible that the first image's URL is ignored once the it´s loaded successfully and the second one loads and is stored under a different variable and so on?
thanks in advance