iosobjective-ctabsdocument-based

IOS Multi-document application


I'm quite new to iOS apps development. I'd like to develop a document-based application, which would handle many documents at a time. They should be opened in tabs and the app window should have a common header toolbar for all the tabs. What is the best way to do it? I've read about tab controller, that it can't be put into another controller, which in turn could hold this tabs and header toolbar. So in short how can I get multitab document-based application?

Edit

Nobody on the line... Well I've got an idea - to do a single view with a button panel (tabs emulation) underneath and by pressing a button I could load a part of document (actually a sheet of it) in this view.


Solution

  • All of this is handled using the built-in document model.

    New document types are created by adding them to the project targets, you only really need to provide a name for the document type, an extension, and the class that handles operations on those types of documents.

    Then simply add new classes, one for each type, and make them subclasses of NSDocument. You need to add the code for loading, saving and displaying the documents. But most everything else is automated, even handling iCloud document support, multiple writers, practically anything you can think of.

    For the display side, that's up to you, but to do a tab interface shouldn't be difficult. Basically you want to have an ivar in your document subclasses that points to a view. The app will automatically have an object holding all the documents. Now you simply add methods in your AppDelegate so when the user New's or Open's it makes a new view to hold the document, inserts it into a tabcontrol, then loads the document. As part of the loading process the document will call its drawing method and presto, it appears.

    In fact, most of this you don't even have to do, it too is build into the machinery. For basic apps with a single document type you typically only have to write maybe a dozen methods, for ones handling multiple documents the only change is a couple of switch statements in various places to look at the document type and do different things (i.e., maybe one document can't be Saved, only loaded).

    Start here: https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/Introduction/Introduction.html