简体   繁体   中英

iOS - How to handle large amount of data from webservice

i am getting large amount of data from web service. If the amount of records it return is more than 1500 or 2000 the memory overflows and the app crashes. 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. Table view help you to reuse your cell and show your 2000 records

For example

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. 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.

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. So some memory management will be needed there as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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