我有一个for循环,当前循环4次。Objective-C - 检查URL是否存在
//Add all the URLs from the server to the array
for (int i = 1; i <= 5; i++){
NSString *tempString = [[NSString alloc] initWithFormat : @"http://photostiubhart.comoj.com/GalleryImages/%dstiubhart1.jpg", i];
[myURLS addObject: [NSURL URLWithString:tempString]];
[tempString release];
}
正如你可以看到网址中有一个数字,得到由1每次循环递增,以创建一个新的URL下一个图像会。但是,服务器上的图像数量不一定是4,可能会更多,甚至更少。我的问题是,有没有一种方法可以检查URL中是否存储了图像?如果没有,请打破循环并继续执行程序?
感谢,
杰克
可能[如何检查一个文件是否存在于特定的URL?](http://stackoverflow.com/questions/2021391/how-to-check-if-a-file-exists-at-particular-url) – zoul 2011-05-15 15:43:10