从iOS应用程序中的ftp服务器下载文件

时间:2011-12-23 05:57:15

标签: iphone ios ipad ftp ios5

我们可以使用iOS sdk的API或任何其他方式从ftp服务器下载文件。 我知道通过http请求我们可以从服务器下载文件。那么我们可以用同样的方式从ftp服务器下载文件,还是有任何不同的ftp集合。

由于

1 个答案:

答案 0 :(得分:3)

NSURL *url = [NSURL URLWithString:@"ftp://user:password@host:port/path"];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];

然后您将把文件导入data


<强> SWIFT:

var url = URL(string: "ftp://user:password@host:port/path")
var data: Data? = nil
if let anUrl = url {
    data = Data(contentsOf: anUrl)
}