Load multiple images from Parse instantaneously - ios

I want to load between 30-40 low res photos from Parse.com instantaneously. Right now I'm using PFImageView to load them but it takes too long to show the next one when I swipe.
What is the best way to load them faster? The objective is to be able to see the next photo without any loading time.

a. You can download the photos right after your app launched and put them into a singleton object. With a singleton you will be able to download them once, and access them from every view controller, so you don't have to download them everytime when a view appears.
These links will help in you in the singleton topic:
http://www.galloway.me.uk/tutorials/singleton-classes/
http://blog.db-in.com/objective-c-singleton/
b. You can use one of the Parse cache policies, check them here.

Related

Initial connection to Firebase seems fatally slow

I've been developing an app that relies on its backend data being available almost immediately after opening. The app's home view is a table view controller that populates each of its cells with titles and then full cell background images. The titles come back quick enough as they are just strings but the images (of which im currently only loading 1-2 of them) on average take nearly 10-15 seconds. Also, when a user clicks one of these cells, this opens a collection view that has to load many more photos. I have been testing this with between 4 and 10 photos so far and it takes between 30 seconds and some times even minutes to pull these down. After these initial loads, it seems to be rather immediate when updates happen..even when several photos get added at once. This could be just the way Firebase stores to to a local copy of the Firebase on the device? Anyway, I was hoping someone could provide some insight as to why Firebase is loading this data so slowly. Is Firebase not capable of powering a photo heavy app? Or is the more likely user error of sorts holding me back?
Thanks in advance!

NSURLSessionDownloadTask resume and Pause from other View ios

I have small problem with NSURLSessionDownloadTask, i.e., in my app user can download movies(nearly 1 Gb), if the user click Pause button and get back to the previous viewController then again he wants to resume the download the downloaded percentage goes to 0. Can anyone please tell how to declare that in AppDelegate.m, or else tell how to resume that video from any viewController and After re-launch that app...
thanks in Advance...
Welcome to SO. In general if you have a specific problem you should provide enough code from your project so your readers understand what you are doing now.
In your case we need information on how your view controllers are linked.
What I would suggest for you is to create a separate download manager singleton class. Set it up with a delegate. Define a delegate protocol that lets you get progress updates on the download percentage. Also implement a pause method.
Both your view controllers would reference the singleton.
If you need to manage multiple downloads from different client objects at the same time then your design becomes more complicated. In that case you might want to look at third party libraries like AFNetworking. They handle a lot of this sort of thing for you.

Where do I cache media for a UITableView? What design pattern should I use?

I'm a new iOS developer pretty far in to my first app.
I have a UITableView that displays a lot of data, with small videos in the Section Headers. Right now in my builds I am embedding the videos in the app, but I'd like them to actually be fetched from a server since it takes too much space.
However, I'm not sure what kind of design pattern to use here. The section headers aren't allocated until they come on screen obviously. If I download the data in the background, and the user scrolls down to the section too early and doesn't get a video, and then the video finishes downloading in the background...how do I tell the TableView to now show the video?
Also, if I don't want to have to redownload approximately 3-4 MB of video every time the user loads up the tableview, what's the best way to actually save the videos somewhere (and delete them on application quit)? So, when the user loads the UITableView, it'll download those videos, cache them, and remove them once the user is no longer needs them?
My first instinct is to have a background thread saving the videos to a special location in the user's documents that is purged on application quit, and run [self.tableview reloadData] every single time one of the videos (each about 200kb) finishes downloading, but I don't know if doing ~20 tableview reloads will impact performance or the user's view (and does reloadData release and reload the section header that is on screen?).
Really appreciate any advice as to how to do this correctly.

Function execution if next view is loaded

I am new to Parse and iOS app development, so please pardon my question if the answer is obvious.
Does a function execution continue if the next view in a view hierarchy (nav controller) is loaded?
I currently have a view where the user takes a picture, which is then displayed on screen. I want to begin the upload and packaging of this image immediately, to save time. So my question really deals with the [saveInBackground] and [getObjectInBackground] functions. If the user taps the button to go to the next view, before the upload is completed, will the functions stop their execution or continue until it completes?
Thanks
Siddharth
As long as you use the function saveInBackground, your photo will be saved even if switching views. If you used saveEventually then the photo would be saved whenever it can (if there is no internet it will upload it when internet becomes available).

A good way to temporarily store data for multiple views in iOS

I have a main view controller that contains a variable amount of buttons (usually 6). When one of those buttons is tapped, I query a server to fetch a stream of information with roughly 40 items, and then I pop that data into a tableview. The stream is analogous to a Twitter stream, and so I can't keep the data on the device since it's always changing.
I can always expect a delay when pressing a button that I haven't pressed before cause the data has never been loaded onto the device. I want to know how I should temporarily store that data. That way I can immediately load the tableview the second time I press the button (from the main view) while the new data is loading.
Let me know if I'm being too abstract.
If you don't want to get into Core Data, I'd say try to serialize out your data into a flat file. Then using NSFileManager, store this file in the application Cache directory. Then when the application launches again, read in from this file before requesting from the network.
Augie's answer to pass this data between view controllers is the way to go during the lifetime of the app. This Cache file would only be necessary when the application terminates and re-launches.
in a nsarray property of your vc and use that array as your tableview datasource
You could simply use an NSArray property , but if you also want the data to be persistent after a relaunch of the app, I would advise you to use CoreData.

Resources