How to cache JSON data for offline reading in iPhone APP? - iphone

I'm new to iPhone development and I still have some gaps that needs to be filled in the first application I'm developing. This app will consume data from a site managed by Wordpress through the Wordpress JSON plugin, which allows to retrieve the posts in the form of a json string.
I wanted my application to store the posts in some form of caching, so that the users would only need to download the new content after the first time. Think about the Twitter App, that keeps all your previous loaded tweets and only load the new ones.
What's the best way to do that, should I save the json as a file or there are another more efficient method to keep it in cache?

I'm currently developing an app that will deal with this kind of stuff. And I found many possible solutions.
If you still have issues with this, have a look here: http://cocoawithlove.com/2010/09/substituting-local-data-for-remote.html
If your app has to be simple, this could be perfect.
An other way could be to subclass NSURLProtocol, but I'm still investigating on this solution.

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!

How to cache whole webpage in ios 4 and above

I am new to iphone development. I would like to know how to do the caching in ios 4 and above??
I got many answers but right now I get confused and don't know from where to start.
In my project, I am doing http request and displaying results using UIWebView
Here,I want to cache the http data. So next time when application starts again then It will reload the data from the cache.
how to cache the webpage data in IOs 4 and above?
I have done with caching of whole web page using ASIHTTPRequest. I go through the ASIHTTPRequest: here is a link to it.
You will have to make use of Core Data to store your data locally by modeling your data in it. You will need to go through the core data programming guide: here is a link to it.
http://developer.apple.com/library/mac/documentation/cocoa/Conceptual/CoreData/CoreData.pdf
After you have understood for how to store your data, you will able to easily able to load this when your app starts the next time.
Im not sure of how to store the web view's data as an html page locally, though that can be an alternative approach too.
I hope it helps you!!! Cheers!!

What are the pitfalls when implementing a web page like app?

I'm planning to implement some app that performs similar functions as some website does. An app should be able to post, get and view some data. Most viewing data is available only after login. Payments. The webservices are .NET asmx XML services.
So, I'm planning to use UIKit, drag and drop some text fiels. For posting the data, I will do some manual input validation, assemble input into a string, post it to the server. Also, some parsing will be done after getting info form a webserver. Now, I haven't done any website app before, so I'm just curious what are the potencial problems that I might run into.
I guess you are asking about potential technical issues. The ones I faced recently working on an app of this type and workarounds are:
Maintaining your session with the server if you are combining native UI screens together with UIWebView's of your website.
XML Parsing can be hairy at times, so JSON is the best option depending on your preference. The other solution is to output XML in the PLIST format which is easier to code against. On the server side PHP has some PLIST generating libraries. Am not aware of what is available on .NET.
On the iOS side the ASIHTTP library helps make it easier to post to websites, particularly when you are using binaries etc.
Depending on your use case you may also consider a pure web based UI version which resides inside a UI webview. If you are planning on going this route JQueryMobile is a pretty good solution for rendering iOS like UIs. This saves you quite a lot of effort on the communicating with the webservice and parsing etc.
Thats all I can think of for now.
Biggest problem might be getting it approved by Apple if they think it should be just a website and not an app. They might cite: "Limited Functionality". see : https://developer.apple.com/appstore/resources/approval/guidelines.html
I can also reccomend www.sudzc.com
Your UI will certainly not be as responsive as a native app.
Your users won't be able to use your app without an Internet connection/flaky connection
You'll have to rebuild all native controllers yourself if you wan't your app to look like a native iPhone app.
You'll have to rely on libraries like PhoneGap to use most of the hardware/non HTML supported functions (like geolocation, camera, etc.)
Etc.

Website Forms to iphone app

I've been researching for ages and still cannot find an easy solution that perfectly. So i stopped and figured i was going about this project the wrong way. All i need is an easy solution.
My project requires me to make a website that has forms (fields include images, text, urls, colors). When the user submits this form, somehow (THIS IS THE KEY QUESTION), gets sent to Xcode so that it can be used in and iPhone app.
My questions: What is an easy to use program to make a website that can do what i said? How does my website connect to Xcode (supply it with the data)? Is it possible for my app to check for newly submitted info?
Keep in mind that i don't have much coding knowledge as far as websites and i only a little about making iPhone apps (Yes, i have made some but not as advanced as this)
Thank you in advance!
It sounds like you want to build an IOS app that can retrieve user submitted data from the server.
Your form will have to post the data to the server where it is stored in your database. Images will have to be uploaded to the server as well.
You can then build a server-side api that returns data to the IOS device upon request. You can have your IOS app regularly request data from the server, receive the response and store what you need on the device.
There is a lot more to it of course, but from what I can gather from your post, this is what you're looking to do.
The workflow you describe doesn't make any sense.
It starts out easily enough: you have a website that has a form with a submit button. No problem there. Hitting submit likely does a POST to a server somewhere. Again, no problem.
Then you say the form data has to ultimately end up in Xcode. This is where things are really muddled. Xcode is a programming IDE for Mac OS X. I'm not sure how or what it has to do with handling data from a Web form. The two things are, for all intents and purposes, completely independent technologies.
Please describe in much more detail exactly why you think you need to "send data to Xcode". Otherwise, your question, as written, is unanswerable.

Seeking iPhone App Architecture Advice: Managing Data

I've built a simple iPhone app that parses data from a remote XML feed, converts the information into objects (they're videos), and displays the videos in a standard table view->detail view->"Play Video" UI. There are hundreds of videos, each with about ten attributes. (The videos are never downloaded, only streamed, using MPMoviePlayerController.) I've relied on the Apple sample application SeismicXML for much of the app's behavior.
Now I'm ready for the next step: saving the video metadata to the device, so that users aren't forced to wait for the XML retrieval and parsing every time they launch my app. I'm planning to use Core Data to save my Video objects (and their parent Channel objects), but it's all brand new to me.
My question is: Can folks recommend any sample application or design pattern for managing this data? I want to have the app automatically download and parse the XML at launch, but then it should refresh the data only when the user taps a Refresh button, or if the data is older than, say, a day.
Apps that model this behavior are NYTimes, AP, and many others.
Besides the excellent documentation that Apple provides for Core Data, are there any resources out there for architecting an iPhone app that needs to download, save, and periodically refresh its data?
Thanks.
Update on 11/12/2009: Between the Apple sample code for TheElements, TopSongs, CoreDataBooks, PhotoLocations, iPhoneCoreDataRecipes, and XMLPerformance, I've got plenty of grist for the mill here. I'm currently analyzing the samples, and slowly piecing together what I need.
Looks like you found all of the Apple samples, so that's good.
The Pragmatic Programmers have a book on Core Data, and several of the iPhone SDK books out (including theirs) touch on Core Data a little. See also this question.
Edit: forgot to mention Three20 (the guts of the Facebook app, Open Sourced) as an example of a way to do this that isn't Core Data. Rather than re-constructing the downloaded data in some object graph that's persisted with Core Data, Three20 implements disk caching and freshness dating on top of the URL loading system. The app basically still works by making HTTP API calls, and parsing the responses, but doesn't have to talk to the cloud on every screen display, which speeds things up immensely. If you're only downloading this information to display in a big table view, and not anything else, perhaps this model might be easier.