How do I update the content of my app without releasing another version? - iphone

I have an app that basically has news and updates about a certain subject. How do I get it to work that when I update something let's say in my website it would also update what's on the app. Do I usee RSS for this?

You need some web service to deliver the data. In terms of what format a web service can use, there are a variety, but two prevalent formats are XML and JSON. RSS is, essentially, a particular form of XML.
On the iOS side, you can parse XML using NSXMLParser (see NSXML Parser Class Reference). If you're parsing JSON, you can use NSJSONSerialization (see NSJSONSerialization Class Referece). For both of these, you can google the class keyword followed by "example" or "demonstration" (e.g., "NSXMLParser example" or "NSJSONSerialization demonstration") and you'll see tons of examples. If you have an RSS feed, you can google something like "iOS RSS example".
It may be dictated by what you can easily render from your server, XML (or, in particular, RSS) or JSON. For example, if you're using some content management system on your web site, it might offer RSS feeds, or something like that. In the absence of that, you may have to write your own server interface to retrieve the data in XML (or RSS) or JSON formats.

In addition to #Rob answer I would point couple mode things:
You can simply prepare databases with your information (like SQLite) and just download them from your web site to your application.
You need to have some way of notifying application about new content and for that you might want to use remote notifications. http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html - this way you can send notify messages to your app, and user will know that there is something new to download and read.

Related

How to create a news like iPhone app that updates weekly

I have created a few small apps for the iPhone so I have some experience. An organization that I'm in asked me if I could program a weekly newsletter app for them. I though it would be a good challenge so I agreed. My question is: how do I get the app to update weekly without the users having to re-download or manually update? Do I connect to a database or a website? Can anyone send me the link to a good tutorial? I wasn't able to find one.
Thank you!
Your question is very general but I could give you some suggestions.
First, you need to connect to a service that provides you news info. This is needed. The service could send you an xml that you can parse and display, for example in a UITableView. XML is not the only solution. You could use also JSON.
For parsing XML I suggest you to read GDataXML, while for JSON JSONKit framework. But there are also other valid framework out there.
Then, to save data it depends on what kind of data you deal with. Here you could find different ways to save your news. Save an XML that contains your news, serialize data and save them in the local filesystem or use Core-Data.
To update your news without user actions, you have to save the last time when the app has downloaded news (for example in NSUserDefaults) and each time time the application is "activated" check for that date and update news if necessary.
Out there there are plenty of tutorials on how to (in parenthesis I inserted classes or framework that you could have a look):
consuming web service on iPhone (ASIHttpRequest - no more supported, NSURLConnection class, AFNetworking)
dealing with XML file/data and theirs parsing (GDataXML, touchXML, etc.)
dealing with JSON messages (JSONKit, etc.)
managing documents (NSFileManager class)
using Core-Data
using Property-List and/or NSUserDefaults
First three cover the first step (download). Other three cover the second one (save). Obviously you have not to use all of them. For example a configuration could be:
NSURLConnection for service, GDataXML for parsing XML data and Property-List for save data.
Hope it helps.
A simpler approach would be to make it a pure web app and update the website weekly.
Your content providers are going to have to do those updates anyway.
Check: Adding Newsstand Support to Your App or Tutorial: How To Make Your App Work With The Newsstand

Parsing Injected Web Page Data

Trying to create an iPhone app (Objective-C) for my school. I want it to search for, and then parse any emergency announcements on the web page. They do not occur in the HTML, and are probably written in with PHP or another server-sire language. Any way i can access that information? (Link: http://www.ridgefield.org/)
I recommend that you parse http://www.ridgefield.org/ajax/dist/emergency-announcements as this is the address where the website fetches the info.
Next time you could use the Firefox plugin Tamper Data found at https://addons.mozilla.org/en-US/firefox/addon/tamper-data/. Try it out!

Iphone: Is SAX or DOM better for this specific problem?

My Iphone communicates with my SOAP web service.
I have a questionnaire in my XML, which includes questions, their answers, and choices of some UI information..etc. So when the user enters a value for a set of questions using the IPhone and sends them back again to the Web service, the Service will add new unanswered questions to that XML.
So a conversation with the Web service starts with an empty XML and builds up to 200-300Kb of XML as the user answers the questions and receives new ones. Since it is a stateless Web Service, all the information will be kept in the XML.
Practically, I only need to find and parse the latest questions from the response XML, which should be good with a SAX parser, and modify only that part of the XML while adding the new answer and sending back again via the Web service the modified XML. BUT the user also should be able to click "Back". So that means I have to hold that XML in memory(200-300KB) and parse when necessary as the user clicks back and next.
My question is which approach is better:
1-Get the XML, parse it totally into objects with the DOM, release XML from memory and work only with the objects as the user clicks back and next. Then when it comes to sending it back, assemble a new XML message from scratch with my objects. Also this approach seems to reduce the clicking time
2-Use the SAX parser and only parse when I need to as the user clicks back and next. But then I have to hold all the XML in the memory. I do not know if Iphone can handle that, and back-next actions should take longer since I parse every time. But the good side is that I don't need to re-assemble an XML from objects again when I am done.
I think the second approach is better, what do you think? And which parser is good for this job?
Personally I prefer DOM XML parsers due to their ease of use and the ability to separate parsing/creating logic from the rest of the code. It seems that your application would be best suited to use a DOM parser because you said so yourself that sometimes you only need certain parts of the XML, not the entire document. SAX parsers do not support random read access.
read the following article and you will find the best solution for you
http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
I would go with NSXMLDocument nevertheless.

How to store data into an xml file on my website and extract the data out of it in my iphone app

In my application i need to create and save data into an xml file on my webspace and then i want to parse that xml into my iphone app. The question here is this is being done by two different parties a sender and a receiver.
But i don;t know how to parse that xml file into my app when i don't have the excat url of that xml because there will be number of people who will be using this app so how i can allocate the xml a specific url and pass that url at receiver end.
Thanks,
As there is a lot to this question I can only give you a vague answer to keep it short. The type of communication I recommend using is NSURLConnection. That will allow you to get the contents of say an xml from a URL.
As far as identifying individual users there is a few ways all of them a fair bit of work. You could create a sign in where the user has a unique username or email. Store that in the database on your server and pass it as part of the url.
You could also sort of use push notification registration where your server is required to keep an iPhone unique identifier to push information to Apple. I don't know enough to push notification to give you much guidance in this but if you don't want the user to create an account I think this would be the way. You could also query the server for a unique ID and store it in NSUserDefaults.
I would recommend the user account creation though. Also have a look at NSXMLParser for your xml parsing.
Beyond this help ask a more specific question. There are also many other ways to do this, its just the way I do it.
I can help you with the parsing of the XML.
iOS (like mac) has a built in XML parser.
Still I would recommend you use an external library, there are several available out there.
In a recent project, I very successfully used TouchXML: http://github.com/schwa/TouchXML
Here is a very simple tutorial on how to use the TouchXML library to parse XML files:
http://foobarpig.com/iphone/parsing-xml-element-attributes-with-touchxml.html

Obtaining information from Webpage - displaying it in an Iphone app

Is it possible to pull information from a website and display it in an iphone application?
I am looking to pull the current temperature and barometric pressure for an airport from the http://adds.aviationweather.noaa.gov website and display those two pieces of information in an app.
This sounds like a common task that programs do all the time but I'm not sure how it's incorporated into an app.. (what is the process of pulling webdata called?)
What methods or tools are available to do this? I am unfamiliar with handling web data for iphone at this time.
If they have an actual feed for the data, you could access it using NSHTTPRequest and parse the results.
If you need to screen-scrape the data off the page itself, then I would highly suggest creating your own web service to do the parsing and have your iPhone app talk to your web service. The reason being that if they update the page in a way that breaks your screen scraping you would only have to update your web service instead of deploying an update out to who-knows-how-many iPhones.
Just use an NSHTTPRequest and all the related classes to assemble a standard HTTP GET request for the site with the data you need. If there's a data feed (XML, JSON, etc.), you should find out what that URL is and use it instead of parsing the actual HTML of the web page. If not, the method is called "screen scraping" and it basically involves you writing a regular expression to parse the HTML of the web page returned from the server. Again, don't do this unless there is no alternative data feed you can use.
If you need to parse XML, see NSXMLParser. There are open-source solutions for parsing JSON in Objective-C. Just Google around for them.