简体   繁体   English

iOS-如何处理Web服务中的大量数据

[英]iOS - How to handle large amount of data from webservice

i am getting large amount of data from web service. 我从Web服务中获取大量数据。 If the amount of records it return is more than 1500 or 2000 the memory overflows and the app crashes. 如果返回的记录数量超过1500或2000,则内存溢出,应用崩溃。 I don't need to save the data locally, just have to present the data to the user. 我不需要将数据保存在本地,只需将数据呈现给用户即可。 How can i manage it not to crash and display whole of the data? 我如何管理它不崩溃并显示全部数据?

You can use paging in table view and also use paging for your webservice.. You can show limited data at a time and if you scroll it then show next data. 您可以在表视图中使用分页,也可以对Web服务使用分页。您可以一次显示有限的数据,如果滚动它,则显示下一个数据。 Table view help you to reuse your cell and show your 2000 records 表格视图可帮助您重用单元格并显示2000条记录

For example 例如

http://www.oodlestechnologies.com/blogs/Pagination-in-UITableview http://www.oodlestechnologies.com/blogs/Pagination-in-UITableview

The best way to go ahead with this would be to change the web service to accept a page param and return paginated results. 进行此操作的最佳方法是更改​​Web服务以接受页面参数并返回分页结果。 To make it look seamless in a tableview, you can add infinite scrolling - ie if the user reaches row <last-10> , send request for the next set of records and load them in the table view. 为了使它在表视图中看起来无缝,可以添加无限滚动-即,如果用户到达row <last-10> ,则发送对下一组记录的请求,并将它们加载到表视图中。

But even with this, I am assuming you will eventually face memory issues if you persist all your 2K records (your data array) in memory. 但是即使这样,我仍假设如果将所有2K记录(数据数组)保留在内存中,您最终将面临内存问题。 So some memory management will be needed there as well. 因此,那里也需要一些内存管理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM