如何在iOS中从服务器接收和存储二进制数据? [英] How to receive and store binary data from server in iOS?

查看:88
本文介绍了如何在iOS中从服务器接收和存储二进制数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPhone(iOS 5)开发应用程序.我要做的是通过使用从服务器获取的二进制数据来创建地图.如果服务器有可用字节,我将它们读入缓冲区:uint8_t [1024].然后我解析这些数据并从中创建对象(例如,包含经度和纬度的点的路径),但是这些对象通常大于缓冲区.在模拟器上,这不是一个大问题,因为我有足够的内存将它们存储到可变数组中.

I am working on an application for the iPhone (iOS 5). What I have to do is create a map by using binary data that I reveive from a server. If the server has bytes available, I read them into a buffer: uint8_t[1024]. Then I parse through this data and create objects (e.g. a path that contains points with longitude and latitude) from it, but those objects are often larger than my buffer. On the simulator this is not a huge problem, because I have enough memory to store them into mutable arrays.

但是,为了使我的应用程序对设备安全,我该如何处理呢?我应该为iOS设备使用什么阵列大小?

But how do I have to handle this to make my application safe for a device? What array size should I use for iOS devices?

我希望我的问题是可以理解的.

I hope my issue was understandable.

推荐答案

您可以使用 NSMutableArray 临时存储数据并根据需要扩展其大小.

You can use NSMutableArray and store data temporarily and expand its size as needed.

希望这会有所帮助.

这篇关于如何在iOS中从服务器接收和存储二进制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆