Storing data into an XML under iOS - iphone

I'm using an NSXMLParser to read data out of a XML, but how can I make my iPhone App storing data into this specific XML.
The case is that I want to create an app to display available dates and one that administrates this dates, whether they are available or not (I'm using an UISwitch to handle this).
Thanks for your answers,
btype.

If you have small amount of data, you can save them in a plist.
See Property List Programming Guide

There's a github project that let's you create XML DOM objects. You can save your XML to your documents folder on the phone.
https://github.com/arashpayan/apxml/

Related

How best to import a lot of text into an iphone app?

I have seemingly a lot of text that i need to get into my iphone app. It's not nearly as much as a book or anything but it would take quite some time to type it all out in xcode, and I'm sure thats not the best way. I read you can import an xml file or maybe a .txt, could someone please point me in the best direction, and maybe a tutorial or something to help me get started?
Thanks!
You can bundle any file you want with your application as a resource. Just include it as part of your project, and then you can load it in your app as an NSString* or NSData*, whichever your prefer/whichever is most appropriate to your data type.
You can also transform the data however your would like, and write some new file that contains the transformed information, and then grab the new file and package that one with the app so that the transformation step no longer needs to be run. For instance, maybe you want to parse your text data and prepopulate a Core Data model with it. You could write the code that does this, grab the .sqlite database file that is generated, and then package the database file in the deployed version of your app so that everyone starts out with an already-populated data model. If that happens to be your use-case here.
What you mean by get text into my iphone app? Do you want to show the text in your application? If yes, why don't you just use the this NSString method:
+ (id)stringWithContentsOfFile:(NSString *)path
encoding:(NSStringEncoding)enc
error:(NSError **)error
If your text needs to be formatted, I would recommend you to use webview to load formatted html files.

How can we store textfield values in pdf in iphone application

I want to store textfield values in pdf file i.e I need to export form values to pdf file just for back up purpose as I cant completely rely on app database so how can I achieve this. Can somebody help me pls. Or can we export data in excel file.
I cant completely rely on app database
Millions of apps rely on Databases! what about XML storage?
XML will be easy to store, easy to retrieve values.
I believe you're looking for xlslib
Good Luck.

iPhone, XML for preload data

I save XML file in Resources folder in xcode. And I parse it when application launches and use it for a default data set. I don't see any problem with this but people are talking about CoreData to handle a default data set. Can I just still use XML file for a default data? what is the disadvantage of using XML for default data set?
I'd say you're fine using an XML file, assuming that the data is small and you're not modifying it a lot. I use a CSV file for a couple of my apps and that's worked fine for me.
With that said, here are better answers to a similar question: Plist vs SQLite vs Core Data for a rss reader type application?

Multi-language documents (RTF) in iOS : Files, SQLite, Core Data ? How?

I'm making my first iOS App, and I'm facing my first (little) issue.
The App will be a very classical iOS UI Experience : I mean, table views, tab bar, push controllers etc. displaying documents (from RTF files already existing), audio and video files.
My RTFs have mixed languages, all supported by iOS, I think it's important isn't it ?
Considering audio and video will obviously stored in the sandbox documents directory, I'm not so sure for the RTF.
I want it to be very reactive, on every devices, so my idea was to store my RTFs in a Core Data entity (using the binary type) and getting it in my application with NSAttributedString which can respond to the initWithRtf message.
I guess that after that I'll have to load it into a UIWebView ? Or simply displaying this NSAttributedString into a textview will preserve it's formatting ?
But I don't know how to ship my application with a Core Data pre-filled database.
So here are my questions :
Is it a good idea to store those RTFs in Core Data ? Is it really faster than a simple UIWebView where I would load the RTF file from documents folder directly ? Maybe SQLite is better for my case ?
How to pre-fill a database into my application ?
Any specific consideration about the multiple languages into my RTFs ? (Latin AND non latin languages into a same file for exemple).
Thanks a lot ! Bye.
getting it in my application with NSAttributedString which can respond to the initWithRtf message.
That won't work. -initWithRTF:documentAttributes: is currently only available on OS X. To convert an RTF file into an NSAttributedString on iOS requires manual parsing of the file at the moment (let's hope that changes with iOS 5).
I guess that after that I'll have to load it into a UIWebView ? Or simply displaying this NSAttributedString into a textview will preserve it's formatting ?
UIWebView can't display NSAttributedStrings. Neither can UITextView. You would have to use the Core Text functions to draw the text yourself. Or use HTML from the beginning and display the text in a web view.
Is it a good idea to store those RTFs in Core Data ? Is it really faster than a simple UIWebView where I would load the RTF file from documents folder directly ? Maybe SQLite is better for my case ?
What's wrong with plain files? That would be my first option because it seems to be the simplest. You shouldn't worry about optimizing something if you don't know if it needs optimizing at all. But since you can store arbitrary binary data with Core Data or plain SQLite, it's definitely possible.
How to pre-fill a database into my application ?
Just include the Core Data datastore file in your app's bundle. If this database needs to be written to, your code needs to copy the file from the bundle to your app's Documents directory on first launch.

How to use Core Data in saving all the details which were stored or displayed in a table view?

I am developing an app which parses an Xml or RSS feeds of a magazine..The thing is I have to include an offline capability,ie save the previous results which were displayed in each cell(similar to the New York times app) and then display the saved ones when there is no network connection..
Please help me with the codewise explanation using Core data as I was suggested to use it for this particular task.
Will be of great help for me..
Looking forward for your replies
Regards and Thanks
Arun
You probably want to start here.
OH Boy... CoreData.
Good bye 3-4 days of learning how this works. You wont regret learning about core data but there is a LOT.
#OhioDude has a great link. You can also.
1. Xcode > file > New Project. Select Navigation Based App, make sure the coredata checkbox is checked. Viola you have a project with all the core data templates.
2. There is other sample code on Apples website.
One of the tricky and cool things about core data is that you if you deploy a new version you have to write a template of how you app is to roll the data into the new structure.
During dev as I am changing the DB structure, I seem to get errors, so I just do a build>clean. And rename the string for the DB file to something new.
Good luck. Otherwise NSUserDefaults will be fine.
Or just learn about PLIST's you can simply serialize a NSDictionarly object into a PLIST and save it to the disk in a few lines of code. SUPER easy and no stuffing around with CoreData.