Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Garrett

macrumors regular
Original poster
Apr 4, 2007
173
0
I was wondering how I could achieve this, I don't need documents and documents of files. I only need one window, when the program starts it loads the xml file. Is there a way when I first start, to check if a say "clients.xml" file has been created in my Application Support folder? If there is one, read from it?

After I can get the initial stage done, I will save it when they quit the application, or whenever they make a change. I just can't figure out how to read from a file.

Thanks in advanced! :D
 

Garrett

macrumors regular
Original poster
Apr 4, 2007
173
0
Anyone?

I just want the program to read from one file is all! Or one "Core Data". :confused:
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I'm not familiar with CoreData, but NSXMLDocument's:
Code:
- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)error

Will open an XML file and give you back an NSXMLDocument * that you can use to parse the file. error will be set if it's not there, so you can likely check that and generate a new, blank document from defaults.

-Lee
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Here's a full app that uses bindings and reads/saves disk-based files.

Look in awakeFromNib in the ApplicationController.m file for the file-handing bits.
 

Attachments

  • BindThisTextView.zip
    79.4 KB · Views: 64

Garrett

macrumors regular
Original poster
Apr 4, 2007
173
0
Here's a full app that uses bindings and reads/saves disk-based files.

Look in awakeFromNib in the ApplicationController.m file for the file-handing bits.
Thanks a lot, if this does what I think it does, then you are a godsend! :D

Edit: I am using Core Data though :'(
 

Garrett

macrumors regular
Original poster
Apr 4, 2007
173
0
I struggled, but I found out how, thanks for your help though!
 

timisted

macrumors newbie
Jul 18, 2008
2
0
UK
Would you not simply be able to use the standard Core Data Application rather than a Document-Based App? That way, it only maintains one 'store' of information for you and you wouldn't have to worry about finding an xml file.
Or, if you do want to be able to specify and find that file, you could change the location and type of the application's persistent store to read and write to your xml file.

Alternatively, in a document-based application, if you've previously 'File -> Open' opened a file once, that document is stored in the app's recent documents list. You could change the default behaviour of a document application to open the most recent document rather than a new one at start up and this would maybe make it easier to find and load the file?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.