Optimize loading of remote plist

扶醉桌前 提交于 2019-12-04 21:40:07

I understand what you mean. You will want to use NSURLConnnection instead of initWithContentsOfURL.

initWithContentsOfURL is synchronous. That means that it will run on the main thread and thus "hang" the application (this is because UI events have to occur on the main thread and if a process is happening (waiting for the plist to download) the app will 'stop').

Anyway - if you use NSURLConnection then you will be able to do it asynchronously (on another thread). This means that for a while your app will be usable, but won't display the data from the plist straight away. So you'll need to handle the view to refresh the data when the connectionDidFinishLoading:.

look it up anyway. :) its very useful

You can minimize load time only by minimizing the plist itself. Try various formats (binary plist, xml plist). If you have an option - try fetching json. AFAIK it has best information-to-size ratio. Binary plist parses fastest and xml plist is best for debugging purposes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!