When running the following lines of code, I see this in the log: Error Domain=NSCocoaErrorDomain Code=256 "The file “some_page” couldn’t be opened
Here is the code:
NSError *downloadError = nil;
NSData *theJSONData = [NSData dataWithContentsOfURL:[NSURL URLWithString:s] options:NSDataReadingUncached error:&downloadError];
NSLog(@"error : %@", downloadError);
This happens only 20-30% of the time
What could be the reason? I found an answer where they say iOS doesn't support http, so I added NS app transport security. But anyway, it happens only sometimes.
Update: I just found out that this is the cause:
if(! [[fullURL substringFromIndex:fullURL.length-1] isEqualToString:@"/"])
s = [fullURL stringByAppendingString:@"/"];
why does it not work 20% of the time with the same url when I add the "/"?