Displaying live ticker data in iOS app - ios

I am consuming data from a REST Web Service via RestKit and would like to display it in a tableview. Consuming the data works really good. Now I want to display the data in a table. The web service is requested every two seconds.
How would you implement the tableview? How to get to know changes? Is there some mechanism in iOS that helps to get the delta?

I think there is no mechanism that helps you out. But you can consume the data on another thread (in the background) and "append" the rows to the TableView, dont use reload than your tableview isn't useable.
Load up your tableview with data.
Start an process in the background wich calls your webservice every 2 seconds.
Create an observer and send an notification when the call is done.
And than append the rows (with animation for example) to the tableview.
I hope that helps you out a bit =]

Related

ios - swift - reload data periodically

swift is outside of my core competency, so I apologize if this is very basic.
I have a page that shows data from a database that is continually updating, I'd like to have this page auto reload the data every few minutes so it is always showing recent data.
1- Reload every few minutes if app is left open.
2- Reload when app is brought back in to focus if it has been pushed to the background.
How should I implement such a function for ios/swift?
Best,

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!

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.

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.

iOS 5 - Where should NSURLConnection go for an app with multiple views?

I am writing an app that has various views; but all of them basically need an access to a connection so they can retrieve data from a server.
Now I was kinda lost about where should I put the code to initialize the connection and retrieve the data.
IF i put it in the viewDidLoad; the connection will be created and the data retrieved every time that the user switch view (I have a tab bar to switch between views); and this is not hat I want (for obvious reasons, the data should be retrieved only if the user tap on the refresh button, and the connection should not be created every time that the view switch).
Where should I put the method that creates the connection and retrieve the data, so I can access this data from anywhere in the app (more specifically the other views of the app; each view show different parts of the data downloaded from the server) and avoid to overload the user and shrink the battery life with continuous connections and data retrieval?
Thanks in advance!
(for obvious reasons, the data should be retrieved only if the user
tap on the refresh button, and the connection should not be created
every time that the view switch).
If you only want to sync the data in response to the user tapping a button, then create a method
- (IBAction)syncData;
and in Interface builder connect the touchUpInside event of the button to the syncData method.

Resources