2012-12-03 82 views
0

好吧,我有一個FTP服務器,它有一個圖像文件夾。這個圖像文件夾並不總是一樣的。圖像的數量可能與文件名稱不同。我能夠通過使用NSURLNSData將圖像加載到我的UIImageView中,並使用指向一個圖像文件的特定路徑,但是我需要從文件夾獲取所有圖像,而不僅僅是一個圖像,以便我可以輕鬆地滑過不同的圖像。有沒有一種方法可以獲取目錄的文件夾,並將該文件夾中的所有圖像作爲數據對象放入NSArray?以下是我用來將一張圖片放入我的UIImageView的代碼。如何從ftp文件夾中獲取所有圖像到NSArray

//This works for loading the one image with a specific full path to the file. 

    NSURL * url = [NSURL URLWithString:@"ftp://myftpServeruserpassportandpath"]; 
    NSData * data = [[NSData alloc]initWithContentsOfURL:url]; 

    UIImage * image = [[UIImage alloc]initWithData:data]; 

    [self.imageView setImage:image]; 

任何幫助或建議表示讚賞。

回答

1

檢查SimpleFTPSample蘋果的樣品,使用FTP operations使用NSURLConnectionCFFTPStream APIs。它可以使用both NSURLConnectionCFFTPStream一個文件download。此外,它可以使用CFFTPStreamupload a file,list a directorycreate a directory

相關問題