Receving large data from webservice in iPhone? - iphone

In my iphone application i have to recieve 1000 images from webmethod . It will take too long time.
Instead of waiting that muc time is there any process to get data from service by part by part.
Is there any possiblity let help me.
Thanks in advance.

Yes. You can do It. I've already implemented that using AsyncImageView which is inherited from UIImageView. What it does is it stores images in Cache memory fetched from a url and whenever you need to load image from the same URL again it will simply load it from the cache memory saving a lots of time.
Just follow the link for implementing that:
https://github.com/nicklockwood/AsyncImageView#readme
http://www.markj.net/iphone-asynchronous-table-image/
Update 1:
Please have a look at the image showing the technique I've implemented it lets you do other activity while images are loading.:

Related

How to fetch an image in the Live Activity (ActivityKit) - SwiftUI

Is it possible to load an image from remote in the Live Activity using ActivityKit? I tried various different methods, but none of them are working including:
AsyncImage
Pre-fetching the image in the App and passing that image to Activity as a Data through the context when starting the activity and converting Data back to the Image
I assume you hit the 4KB size limit the docs warn us about.
We are not allowed to make network requests from inside Live Activity widgets, thus the only viable option you have is downloading the image in the App.
Depending on the type of image you use, I advise you find some way to reduce their size by either downscaling, using vectors etc.
Good luck!
I managed to share images from my main app to the Live Activity or Dynamic Island via Core Data.
However for some reason it works fine on Simulator but it doesn't work at all on real device.
The Live activity starts without error, but it doesn't appear on Lock Screen as well as the Dynamic Island.
Sharing an Array of Data containing images, looks like resulting in an error while starting the Activity.
So I really have no clue at this point.

Asynchronous downloads in iPhone

I can able to download a file when an URL is given using the delegate methods of NSURLConnection. When a download is active, its download progress like percentage downloaded, transfer rate, bytes received are shown in the UITableView. So, when I initiate a download, the first cell of the table is active till the download completes. Everything is perfect for a single download.
My problem is, I have no idea how to handle multiple asynchronous downloads. If the URL is given when a download is active, the second cell of the table should be activated and the progress should be shown. I surfed many blogs and forums regarding this. Many suggested to use ASIHTTPRequest. But I am trying to handle the NSURLConnections in an array and hit the requests. When I tried, the first active download is overridden by the second request.
Please help me with some ideas to deal this problem using array, without ASIHTTPRequest. Thank you in advance.
Assuming that you're making multiple NSURLConnection objects, one per request just store the connection that each table view cell is referring to in an array.
Then, when the delegate methods are called, they should all pass back the connection object that they are referring to i.e. connection:didReceiveData:'s connection parameter.
You can use this parameter to work out which table cell this delegate call is referring to.

issues with UITableView performance

I am pulling data from a web service in order to populate my UITableView rows. It loads perfectly fine, however it takes around 4 seconds in order to load the whole data. Is there a way in that I can increase the time to load? Probably by caching it? Or any tips and tricks on what people usually do to do this?
You can display old data and asynchronously fetch using threads the new data and then reload the UITableView
Caching depends on what you're loading. If you're loading, say, Twitter feeds, you should cache the user avatar pictures because you know you'll be fetching them over and over again. If you're writing something like a retail app, you might show items that are on sale. If the items change every Sunday, then cache them the first time you fetch them and don't fetch them again until Sunday. That sort of thing.
Beyond that, there's not much you can do to make the internet faster. If you have control over the web service, you can make the data sent back as concise and simple as possible. You'd be surprised how many milliseconds you can burn parsing complicated XML.
If it makes sense for your app, you can show old data. For a twitter client, it's better to just save the data you've already fetched, show it immediately, and load the new stuff in the background.
If you can't do any of that, then pretty much all you can do is put up a "Loading..." overlay of some sort so that the app doesn't just look frozen and live with the delay.
You can try to use Three20 TTTableViewController, nice tutorial can be found here:
Three20
Moreover, you can add "Load more results" button, look here

iPhone Download Meter

Hi
i have plan to develop app similar to
http://itunes.apple.com/app/download-meter-for-wi-fi-3g/id327227530?mt=8
Please suggest me, which api's i have to look into?
Any tutorials avilable?
Thanks in advace.
You want to be looking into the UIProgressBar object, and the related delegate methods. When you open a NSURLConnection, you can retrieve the expected size of the thing you are downloading (this method will vary depending on where your data is coming from).
The NSURLConnection will download the object in chunks, calling the didReciveData method every time it receives a packet of bytes. Here you can calculate the percentage of the file downloaded (it will be decimal format, ie. 0.74/1.0) as you append the data and update the progress bar accordingly.
Check out the tutorial HERE

iPhone: Load Queue on Startup

I've not found a answer to this question anywhere, but this seems like a typical problem:
I would like to send some POST-Requests (with ASIHTTPRequest, what I already do), but if something goes wrong, ther user can decide to "Try Later", that means, the task should be put on a queue and this queue should be read next time the application starts. So, that's my question: how to "save" the queue, so that the app can read it next time it starts? Is it possible to "read" the queue and try sending this POST-Request again, let's say, 10 min later, even if the application is not running?
What kind of documentation should I read in order to be able to do this?
I would be very glad to hear any answers. Thanks in advance.
P.S.: Another Idea I have: as I just have to Upload Photos, I could have a folder with all the Photos that still need to be uploaded, and when the App starts, the app looks at this folder and try to send all the photos in this folder. Does it make sense?
My approach for this issue would be like this:
Whenever you fail to send details - write content of the array to a file using '[NSArray writeToFile:]' you can use serialization if array contain any data which is custom defined (if your array contain standard cocoa objects(NSString,NSData etc) they already implemented with serialization )
When app launches; load the content from file directly to an array object ('[NSArray arrayWithContentsOfFile:]')
then construct http request and try sending. In application the data(in your case array) is stored/serialized not the request, you need to reconstruct the http request when you want to try one more time.(don't try serializing ASIHTTPRequest, you have reconstruct it)
I'm going to assume you've already looked at NSOperationQueue and NSOperation. AFAIK there is no built-in support for serializing NSOperation, but you could very easily write your own serialization mechanism for an NSOperation subclass that you use for posting data and write the an NSOperationQueue's operations to disk if something goes wrong.
Without knowing too many details it's hard to give a precise answer. There are many ways to write data to disk and load it again later, the direction you take will be largely dependent on your situation.