Add a second UIViewController within a single-view application - xcode

I have a single-view application open. I need to have two storyboard views (UIViewControllers), because one is a Table View, but when one of the Table View elements is selected it brings up another screen with a normal UIViewController. Is there any way of creating a second storyboard view (UIViewController)?

Of course! Those templates Xcode provides are in no way "set-in-stone". When Xcode created your Single-View Template, it just gave you a base for creating something more. You can create additional classes, view controllers, views, and resources (other than what Xcode starts you off with in a few ways).
To add another View Controller to your Storyboard, just drag and drop one from the Object Library:
It seems like you do not have a basic understanding of using or developing with Xcode. I would recommend reading over all of Apple's documentation on Xcode before going any further. The Building A User Interface section may be of particular interest to you.

Related

How to find the editor for multi view controllers

I am very new to xcode, got stuck in finding the editor to modify the code when created multiple view controllers. Whenever I click on any of the view controllers, I only see same editor contents and cant move to the others for coding.
I searched the web and stackoverflow but could not find a clear guideline on how to manage the editors for multiple view contollers. I have attached a snapshot.
You don’t “find” code. You create it.
When you drag a view controller into the storyboard, it has the default class of UIViewController. It is up to you to make a new code file where you subclass UIViewController, and then to go back to your storyboard and change the view controller to that subclass in the Identity inspector.

Cocoa how to handle multiple views?

I'm have done some development on iOS using Storyboards. Now I'm building on app for Mac OS X and it seems that an equivalent for Storyboards does not exists.
For instance, I'm need to build some kind of wizard, which contains four different windows or views (step 1 to 4).
Currently I've created one Window xib (the standard MainMenu.xib), containing a window with the first view, and three other custom views. Using this approach, I can create outlets and actions, making me able to change the contentView of my window, e.g. when clicking an button. This seems as a fair solution, and my views are all grouped cleanly inside a single xib. But this also cause that the logic for all the view should be handled by the same File's Owner, right? For instance saving the settings on each step and controlling the interaction between the different views.
How is the preferred way to handle a situation like this? Should I instead create four different windows, and maybe in four different xib-files? If you know an sample project somewhere from the internet showing how to handle multiple windows, please give me a hint.
You can make use of the NSViewController class for this purpose. Each view controller will be responsible of loading a xib associated with it and all logic associated with the views can go inside the controllers (Same as in iOS). The MainMenu.xib can now load appropriate views after initialising the required view controllers.
Here is a sample app for your reference.
https://developer.apple.com/library/mac/samplecode/ViewController/Introduction/Intro.html
In xcode, go to File->New->New File
Add an objective C class and set it to subclass of "NSViewController".
This will itself create yourController.h, yourController.m and yourController.xib.
Now you can keep your view and its controller class seperate.

Steps to convert a new xcode cocoa project using 1 controller per nib

I want to start off my new xcode project using 1 nib per controller. By default it seems xcode creates:
1. delegate .h/.m
2. MainMenu.xib
And looking at the targets for the project, I see that the 'main nib file base name' is set to MainMenu, the principal class is NSApplication.
Since cocoa is MVC based, how are things MVC based on the default template?
How can I wire things together with a 'MainWindowController' instead of this default setup? If someone can explain the steps to me that would be much appreciated.
You don't want to subvert or change the default setup, just to understand it and work within it. MVC is a description of responsibility rather than some hard requirement about naming.
The delegate .h/.m is the app delegate by name, but its responsibility is to be the app controller. It gets everything setup when the app starts and deals with application level events. It shouldn't do anything that isn't related to application level management.
The MainMenu.xib is just a container / archive of the first Views and Controllers that are to be created when the application opens.
There is no Model in the template really as all it does is display the main window with a static string on it...
Your goal of using 1 nib per controller is fine, but you should be a little flexible with the naming at first. Because the MainMenu.xib contains the main window it should also contain your MainWindowController. This is perfect from an MVC point of view because you are separating the responsibility.
Then, your future Controllers and Views (in their XIBs) can have matching names to keep everything clear. And you can created your Model separately.

Enable Edit Menu for NSTableView

I'm new in cocoa but with some experience with Cococa-Touch. As I am developing a OSX Lion app that uses tables (NSTableView and NSOutlineView), I am having troubles trying to add copy-paste features to tables.
I have no problems with drag-n-drop features that I have coded in table view controllers. But I cannot make edit menu options (copy and paste) enable.
I did read apple documents, but I'm missing something. I can't make it work. Can you please guide me with the first steps to enable that edit menu options and attend them from table view's controller?
I have solved it, so I answer my own question.
I have subclassed NSTableView and NSOutlineView and, in the new class, included the methods: -validateUserInterfaceItem: , copy: and so on. I was erroneously expecting to receive actions in Table Delegates.

Different types of Xcode applications

I am new to Xcode development. When I first opened Xcode 4.2, there were different types of applications we can build (Master Detail, Page Based, Single View, Tabbed, Utility, Empty Application) using Xcode.
I am somewhat confused about how different they are from each other. I did some search but so far I am not able to understand their basic difference. How would I know which application to select to start developing my own application.
If someone can explain their difference and usage to me in layman terms.
Thanks.
Those are different starter template's provided along with Xcode. You may decide not to you use any of the templates and go with an empty project.
Below is the brief overview of each of the templates.
Master Detail - Template which has pre-created Parent-child views with navigation controller, typically for iPad for different orientation.
Page based - Similar to iBooks app.
Single View - Starter template with a single view. you can add multiple view whenever required.
Tabbed application - View controller with tab bar at the bottom of the screen.
I hope you got the idea. In my opinion, as a starter, you should go with creating a single view based application.
Good luck.

Resources