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

osici

macrumors newbie
Original poster
Apr 8, 2009
3
0
Hi everybody,

I'm pretty new to Objective-C and Cocoa but I've done a decent bit of programming with C and C++. I'm having trouble wrapping my head around how to use files and documents under cocoa. I'm trying to add file loading ability to a program that wasn't written originally as a Document-based app.

What I want to do is load text files with a specific extention from the 'Open' menu item, and then chop them up as needed and store them in a subclass of NSDocument.

I've added a subclass of NSDocument that will be storing the contents of my files once loaded, and I've connected the 'Open' menu item with openDocument in the FirstResponder. I haven't implemented readFromData and dataOfType yet, as I don't understand how these are connected to NSDocumentController/whatever else handles files that have been opened, that is, where the NSData object comes from, and what the openDocument method actually does.

I'm under the impression that things can be simplified using archivers. The problem is my files are going to be written by an external program and will be text files I'll be chopping up once loaded, so I'm guessing archivers aren't what I want.

I've done some searches and read the documentation but I'm not sure what I'm really doing here, so any help to understand the structure of the file loading/saving system would be appreciated a lot:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.