【发布时间】:2016-04-21 06:21:14
【问题描述】:
我正在尝试快速从流中获取数据。我知道如何在 Android 中处理这个问题,但我不知道在 iOS 中该怎么做。 在 Android 中,我执行以下操作从服务器读取数据并将其作为文件保存到我的设备:
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.connect();
input = connection.getInputStream();
output = new FileOutputStream(context.getFileStreamPath(filename));
byte data[] = new byte[1024];
int count;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
File file = context.getFileStreamPath(filename);
我怎样才能用 swift 做同样的事情?我正在使用 Alamofire 处理其他请求。
最好的问候
【问题讨论】:
-
你解决过这个问题吗?我正在处理涉及相同类型情况的事情。
-
很久以前,但我相信 alomofire 可以解决它。
标签: ios swift stream alamofire