我有一個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