When to persist data in iPhone application? - iphone

I'm currently creating an iPhone app where in one part of my app you can view your twitter stream. I'm unsure if I need to ever save the twitter information to a sqlite database or not.
So here is the flow of this part of the app:
press button to see twitter stream
go get twitter stream
display twitter stream in table view
I'm wondering if I should ever save the twitter stream into a database. Any advice?

I would say you should save the twitter stream. You should almost always try to save some application state in an iPhone app. This way, if the user is interrupted (a phone call) they can jump back into your app without missing a beat.
There are a few different ways to persist data in an iPhone app. Instead of bothering with using a SQLite database you will almost certainly want to use Core Data, which is new in iPhone OS 3.0

If you won't ask the user to provide his/her twitter credentials and it will be an anonymous stream, you don't need to store anything.
But the minute you want to store some preferences, actual state (to show the user what he/she was seeing when a phone call came or after application restart) you will need to store persistent data.

I think it's important to cache web data. With a cache, you can present data immediately on app startup - this is important on the iPhone OS because users are constantly opening and closing apps. Having your data immediately available is a big win for the user.
You can make the caching very simple, just have a single table with the URL as one column and the HTTP response as a second. Then you don't have to change any of your code to make the caching happen.
Alternatively, you will need to define a data model and manage that through CoreData or sqlite.

Related

how to load data from an external database into an iPhone app

Basically what I want to do I be able to enter in data on a website, and have it appear on an iPhone app, so I want it to send the data to my iPhone, and store it so that every time i open the app, it will re load the data and put it on the screen. How can I go about this?
You will need a backend-side to your app. If you don't have any experience with backend-developing, I would recommend taking a look at Parse.com or other similar backend providers. They give you a server-solution without having to develop it yourself.
Good luck, and welcome to SO!

Accessing Database using node.js in iOS

I want to create such a application in which my iPhone will have the UI for entering the data for the employees. After clicking on the post button data should be saved on the sqlite database and I also want to retrieve the data on button click from the database. I want to use node.js for communicating between my iOS app and the database. Since I have never used node.js before, please give me some links where I can study the sample applications.
I am not an iOS developer but I would make a REST service in Node.js that can sit between your Iphone app and your database. You most likely are going to want to have some form of authentication on the service.
Also does it have to be sqlite? There are databases that can understand HTTP. If you use CouchDB (there are others) you can let your app talk directly to your database. That means you can leave out Node.js completely. You can go even further and use a service that will provide a back-end for you. Something like parse.com (there are others) will do this for you.

Client Server with IPad

I have a bit of a design question if anyone at there cares to offer some advice (or point me in the right direction).
I am writing an IPad app that will be gathering data from a server and then will be using that data for some time (read: it would be nice to be able to store the data locally even when the app is not running). Anyone know of the best way to accomplish a feat like this.
Essentially, order of events would preferbly go something likes this:
User launches app.
IPad requests data from server.
Server supplies data.
User interacts with app etc.
User closes app.
At a later time, user launches app again.
App checks data, sees it is still up to date, reads in previous data from disk.
User interacts with data etc.
Thanks in advance.
When the application is launching for the first time you should get all the data and store in to a local database.
When the user open the application after some other time just write make a webservice call that check for the last updated time, if it matches your time then leave it,else update the database.

How to store/retrieve application data incase application deleted accidentally

I am having an application in which I am having SQlite database too ..If I delete that Application accidentally. Is there any way to get back the same application with the same database.
Or Is there any way to keep database alone in a separate place inside iPhone memory so that we can recover after application delete if needed.
Please tell me how to achieve the above?.
Regards,
V.K.
Every iPhone app runs in a "Sandbox", which is where it stores its application files and databases. When you delete the app, the whole sandbox is deleted, including your SQLlite database. There is no way to write it outside of the sandbox short of having another app that listens on a URL and having the app in question write to that URL.

Best practice for sending data updates to iPhone app?

I'm currently in the middle of developing an iPhone app with a big reference database (using Core Data backed with a pre-populated sqlite database). Once the app is live and deployed to a client's iPhone, I need the facility to update/insert a small amount of data. What are best practices / methods for doing this?
There may be occassions when the frequency of updates will be daily for a month or so. Other occassions when a data update happens once every few months.
What is the recommended way of doing this? Note, I don't anticipate any data model changes for these updates -- this is purely an insert/update of data.
At the moment I'm starting to research the use of push data notifications (q:payload size restrictions?), app store updates (q:code/data model only, not data updates?) and the use of my own ad hoc data server (which the app connects to routinely to check for updates).
Can anyone please provide me any pointers on the above?
Thanks in advance
IIRC Push Notifications have a maximum payload of 256 bytes. Enough for notification purposes, but not more. Your app would still have to download the actual data from your own server after receiving the notification.
Note that the app bundle is not writable on the device. So if your app needs to update the data store, you should copy the pre-populated database file from the app bundle to the app's documents directory on first launch.
App Store updates would certainly be feasible (especially now that Apple seems to have gotten its review process down to a few days at most) but note that an App Store update will always replace the entire app bundle (code and data), so if your pre-populated reference database is big, the customer would have to download it in full every time.