【问题标题】:How to get all images from ftp folder in to an NSArray如何将 ftp 文件夹中的所有图像放入 NSArray
【发布时间】:2012-12-03 06:28:44
【问题描述】:

好的,我有一个包含图像文件夹的 FTP 服务器。这个图像文件夹并不总是相同的。图像的数量可能与文件名不同。我可以使用NSURLNSData 使用一个图像文件的特定路径将图像加载到我的UIImageView 中,但是我需要从文件夹中获取所有图像,而不仅仅是一个这样我就可以轻松滑动浏览不同的图像。有没有办法我可以获取目录的文件夹并将该文件夹中的所有图像作为数据对象放入NSArray?下面是我用来将一张图片放入我的UIImageView 的代码。

  //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];

感谢任何帮助或建议。

【问题讨论】:

    标签: objective-c xcode uiimageview xcode4.5


    【解决方案1】:

    使用NSURLConnectionCFFTPStream APIs 检查来自苹果的SimpleFTPSample 样本,该样本使用FTP operations。它可以使用both NSURLConnectionCFFTPStreamdownload 一个文件。此外,它还可以使用CFFTPStreamupload a filelist a directorycreate a directory

    【讨论】:

      猜你喜欢
      • 2021-02-17
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-24
      • 1970-01-01
      • 2019-05-14
      相关资源
      最近更新 更多