Core Data object graph to XML file - objective-c

I'm not asking for a solution, but rather what topics I should be reading for the optimal solution for this problem?
I want to read whatever I have in my object graph and write it in an xml file.
I think I can fetch every object manually, read them and then write them to a file. But I dont think this is a good approach to this problem.
Can someone be my guidance?

Check out RestKit. It is meant for talking to server from iOS devices but it also works as an app and has a very powerful object model. You can probably abuse it to serialize your object.

Related

Core Data need help(beginner)

I trying to make a Web Service application which will run when the program is on the background too and i will fetch my data from tree different URLs from my server. I read almost all of this and also this tutorials and even i watched CS193p Core Data Lectures too but still i cant get started with coding. This is my first Iphone(ipad) application, i use NSJSONSerialization for parsing. Can anyone please explain a little
How many ManagedObjectContext s i need to declare?
How to save data which come from different classes to the same entity?
(The mos important) From where to get started with coding..
I think this is a kind of not wanted questioning but i really need help. Thanks in advance
I would suggest taking one of the core data sample apps from the ADC site and looking at how it's structured. You may even be able to adapt the code to your application. CoreRecipes is a great sample to learn from.
https://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html

how write XML for any website

I am doing Objective C programming and I want send and receive requests(Login/data fetching) over the client/server.
Now the problem is Should I do it using XML or any other Method.
Also I know nothing how to write XML for any particular website.
I am hassling for many days.Can anybody help?
XML particularly SOAP is very bloated and the support in Objective-C is severely lacking. I would recommend JSON for lightweight use and in fact Apple use it for their Push Notification server.
If you DO want SOAP then check sudzc.com for an online objective-c generator from a WSDL.
There's no such animal as "any particular website." Some return data in HTML, RSS, ATOM, or JSON format, others may use a custom XML schema all their own. Likewise with the data you send; they may expect requests via SOAP or HTTP, with any type and number of inputs the creators chose.
In short, you need to find out exactly what is expected by the one particular site with which you're trying to communicate, and give it what it wants. That's why programmers get paid the big bucks, because there's no easy "do what I mean" button. :-)
Your question is whether you should use xml or any other method of communication.
XML has been designed to standardize communication, which is especially handy for communicating between several parties, as the structure of the document can be formally written down in a document and can be validated, so there is no discussion afterwards about the syntax of the document.
Although that is a noble idea, XML is relatively complex and not as light weight as, for example, json.
As long as you are writing your own client that communicates to your own server, the protocol used between those 2 can be anything, and do not need to be XML.
Therefore I would suggest using a lightweight and easy to understand protocol. Json is gaining popularity due to its simplicity.
If you have control over the output of the data on your server, I'd suggest you output the data directly as a plist. Plists are native dictionary objects that can be directly instantiated with [NSDictionary dictionaryWithContentsofURL:].
Take a look at the PList programming guide for proper formatting.

Use SQLite, plist, or something else?

This is more of an opinion question than technical.
I am writing a basic app to get into UIKit, MapKit etc. I want to store some basic information such as location data, some strings etc, nothing crazy and not too many (several hundred). I wondered if I should go with SQLite or use plist files? I will release app updates, so don't want anything where data would be lost.
I'm leaning towards SQLite, but wanted to ask the opinion of people in the know first.
If you'd like to know more about the app to help make a decision, just holler. :)
You could use NSUserDefaults. They are simple to use and you can create them on the fly. If the user deletes the app, the prefs will be deleted, but if they simply install a new version on top, the prefs will remain.
A really good method to store persistent data on iOS devices is the Core Data framework. Check out this tutorial for a good introduction. There is also a good comparison here of the different data storage types. Hope that helps!

Is it advisable to send/return data in .plist format to/from an API being accessed via iOS?

We're deciding between using JSON vs. Property List (binary) for our API, which will be accessed by iPhone/iPad/iPod Touch.
Are there any speed advantages?
The server guys are going to understand JSON better.
Plists work really well and have much, much better type safety. The real issue you'll run into with JSON is someone server side adds a few quotes around a number and suddenly your app is crashing.
But, JSON is compact, easy to read (unlike binary plists), and as noted is really well understood. So just be very careful in the parsing code, and try out JSON.
According to Sam Soffes, JSON.
edit: he talks about xml-based plists, not binary plists. Either way, json will typically be easier to generate from web based api's.

Data serialization

I've got an Objective-C/cocoa based application that I'm working on. This app is client<->server. Currently, the communcation protocol is based upon some fairly simple XML. While XML works for this task, it is not ideal in any aspect. It's a pain to serialize data to XML, it's not particularly light-weight, and difficult to incorporate non-data information (such as: 'do this next') in.
I'm looking for suggestions to an alternative.
I've considered some of the ones listed here, but haven't decided on any. Suggestions?
If you are talking to a Objective-C server you can look into encoding and decoding with the preferred serialization methods available in Objective-C.
NSKeyedArchiver and NSKeyedUnarchiver
Basically you will get an NSData from the NSKeyedArchiver that you will send (bytes/length) to the other part and there place it back into an NSData and use NSKeyedUnarchiver to unpack it into objects again.
I'm using JSON for an iphone application - I typically would prefer XML, but we needed it very lightweight, so we decided on JSON.
If your working with XML, you should take a look at XPath if you've not already - it will give you tremendous power for extracting values from a XML data structure.
What kind of server do you have? If the server is java based I'd recommend looking at HessianKit by Fredrik Olsson. Encode/Decode to ordinary Objective-C types and put in NSArrays and NSDictionaries will make the experience smoother.
What's wrong with (Portable) Distributed Objects?