iPhone app server communication XML or JSON? - objective-c

Which method is easier and more efficient? XML or Json
Where can I find a tutorial and code samples for each?

I recently learned how to use JSON on the iPhone and it was very easy.
Here's a framework:
http://code.google.com/p/json-framework/
General JSON info can be found here:
http://www.json.org/

Related

How to parse a simple XML file using Xcode 4.2.1

dont get to harsh on me for asking this question, I know this has been asked many times. But the examples I found on the internet are either old or I am having difficulties to port them on to iOS5-Xcode 4.2.1. So I am really looking for a updated simple example where I can parse a simple XML file from an URL, store the values and display them in a tableView. I am looking for some working examples using NSXMLParser. In case if one of you guys have some info about where I can find a working example/internet link which I can follow and make it work on my machine, so that I can play and get some hands of experience on dealing with XML data, before I go on to work with the complex XML data files.
Any one who can post some code is also highly appreciated, as it would help beginners like me.
have you checked this tutorial of parsing XML data with NSXMLParser -
http://wiki.cs.unh.edu/wiki/index.php/Parsing_XML_data_with_NSXMLParser
i think your are looking for this.
Also there is an another good way to do this is using TBXML framework - https://github.com/71squared/TBXML

Processing JSON output in iOS

I made a very simple wordpress plugin that prints some posts in JSON format. I was wondering what is the best and simplest way is to process that information in Xcode.
I've seen many examples and many frameworks but I would like to hear your opinion and maybe some example code?
Thank you.
If you are targeting iOS 5.0 and later, the simplest way is using the NSJSONSerialization class that Apple provides.
As rob said if you're targeting iOS 5 use Apples NSJSONSerialization class. For earlier iOS versions there area also some options:
JSONKit (fastest)
SBJson
and others ...

How to Read Parse XML in Objective C?

What framework I should use to grab XML from a http and parse that?
Start here:
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
You can use the initWithContentsOfURL initializer to actually load the document from the HTTP source.
Try touchXML:
TouchXML is a lightweight replacement
for Cocoa's NSXML* cluster of classes.
It is based on the commonly available
Open Source libxml2 library.
Here is a nice tutorial.
Source has moved a bit, can be found here

How to get and parse JSON using objective C?

Is it possible to get and parse JSON using objective C, then manipulate it within the cocoa framework for the iphone/pad? I'm specifically looking to do this for a couple of public APIs out there.
See here: how to do json parsing in iphone
Basically, you should look into the TouchJSON library (with CJSONDeserializer and CJSONSerializer).
Used Json-framework on some previous projects, worked really well.
EDIT: I read your post a bit too fast. I've used it on a Mac app before but not targeting the iphone/ipad. I think it should work but have no background to it. Maybe someone else can confirm?
It's not only possible, it's dirt simple if you use one of the many existing open source projects dedicated to this task. I recommend trying yajl-objc, which offers a streaming parser, but json-framework is a good one too. They're very similar.
I'd stay away from TouchJSON, since it gave me trouble a while back with special characters (line breaks) in strings.
However, I'll join the choir recommending json-framework. Since I switched to that from TouchJSON everything's been running smoothly.
Regarding how to integrate the API in your project, they're equally simple to include and use.
As a side note, I'm just now testing out JSONKit, since it's supposed to be much faster than both TouchJSON and json-framework. However, I can't vouch for its stability yet. The reviews of it are good, though.
If you're developing an application that is only iOS 5.0 or later, you can use NSJSONSerialization.

Objective-C Library for RSS feed parsing?

I'm looking for an Objective-C library for an iOS app that will parse and display articles form an RSS feed.
Specifically,m I'm looking to make an app for a news website. The framework should be able to work with various RSS XML structures if possible. (Well, two different news sites. One uses Wordpress-generated RSS and one does not.)
MWFeedParser is another interesting library to look into.
How about https://github.com/touchcode/TouchRSS?
My drop-in solution (deals with Wordpress' RSS 2.0 and the Atom 1.0 format as well): http://github.com/H2CO3/RSSKit
You could use Apples NSXMLParser Class. Or you could use the C-based libXML2.
This library is about as old as this question: https://github.com/NextfazeSD/WordPressSyncer. It syncs WordPress blogs from the server, saving data locally in a core data database.