Questions tagged [nsviewcontroller]

An Objective-C object that manages a view, typically loaded from a nib file.

The NSViewController object manages a view, typically loaded from a nib file.

This management includes:

  • Memory management of top-level objects similar to that of the NSWindowController class, taking the same care to prevent reference cycles when controls are bound to the nib file's owner that NSWindowController began taking in Mac OS v 10.4.
  • Declaring a generic representedObject property, to make it easy to establish bindings in the nib to an object that isn't yet known at nib-loading time or readily available to the code that's doing the nib loading.
  • Implementing the key-value binding NSEditor informal protocol, so that applications using NSViewController can easily make bound controls in the views commit or discard the changes the user is making.

For more information on the NSViewController object, check Apple's NSViewController Class Reference.

410 questions
4
votes
1 answer

NSContainerView with multiple child view controllers in Xcode 6

I'm trying to link two different view controllers in an Xcode 6 storyboard with a NSContainerView so that they can be switched conditionally. Unfortunately this tutorial here isn't of any help since things seem to have changed since in Xcode. So I…
BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
4
votes
0 answers

Xcode OS X use NSToolbar to change views (swift)

I have a storyboard with a window controller. That window controller has a NSToolbar with 2 NSToolbarItems, view1 and view2. This is the code for the WindowController: import Cocoa class MainWindow: NSWindowController { override func…
Carl
  • 43
  • 6
4
votes
2 answers

how do I switch between NSViewControllers using NSPageController?

I have had bad luck finding any examples on the web that closely match what I am trying to do. I am trying to using NSPageController to view and switch between multiple NSPageControllers. My steps. I create a new OS X swift project I add an object…
Alex
  • 122
  • 1
  • 7
4
votes
1 answer

How do you get a custom view controller to load its view into placeholder in another nib?

So, create a custom NSViewController subclass with xib/nib. Then in the app's main nib, add an NSViewController object from the object library, set the class to the custom view controller class. Create IBOutlet in the app delegate for the custom…
uchuugaka
  • 12,679
  • 6
  • 37
  • 55
4
votes
3 answers

Getting Key down event in an NSView controller

I'm trying to find a solution that allows me to get keydown events in a view controller. I do not believe a view controller is part of the responder chain by default. I would appreciate a sample of how to go about this. I have had trouble finding…
Miek
  • 1,127
  • 4
  • 20
  • 35
4
votes
1 answer

NSViewController for each row in View-Based NSTableView?

Usual good practice in Cocoa dictates that each NSView should have its own NSViewController as its owner. Should this apply to each row of a View-Based NSTableView and, if so, what's a good strategy for initializing and caching these…
Anonymous
  • 1,750
  • 3
  • 16
  • 21
3
votes
3 answers

Instance variables lose value after initWithNib and before IBAction in NSViewController

I have a very basic initialization problem with an OS X app I am writing. I am initializing instance variables in initWithNibName in my NSViewController. However, these variables lose their value and end up being equal to nil by the time I access…
Kevin
  • 96
  • 1
  • 5
3
votes
1 answer

Accessing parent view when adding subview

I have a ViewController that has 2 NSViews in it of different sizes. I'm wanting to add the view of a custom ViewController as a subView to both of these NSViews and have it dynamically size to fill (the 2 parent views). I can accomplish this just…
Ethan
  • 628
  • 2
  • 6
  • 20
3
votes
2 answers

Add lots of views to NSScrollView

I'm trying to add one subview (view from an NSViewController) for every element in a dictionary to a NSScrollView to get kind of a tableview, but with much more flexibility over the cells. Is it possible to place (programmatically) e.g. 100 subviews…
3
votes
1 answer

Access to AppDelegate methods from NSViewController

I'm trying to execute a method present in AppDelegate from my NSViewController class. I tried this line to access to the AppDelegate : let appDelegate = UIApplication.shared.delegate as! AppDelegate; Without success : Use of unresolved identifier…
Antoine
  • 135
  • 5
3
votes
1 answer

Custom NSStoryboardSegue not adding NSViewController to Responder Chain

Overall goal: Use a custom storyboard segue on macOS The issue at hand is the responder chain. According to Apple: In addition, in macOS 10.10 and later, a view controller participates in the responder chain. NSViewController If I use a standard…
Zelko
  • 3,793
  • 3
  • 34
  • 40
3
votes
1 answer

What's the standard way for NSDocument to send events to NSViewControllers?

(Background: I've got a Cocoa app I'm writing that works fine, but is too complex because it doesn't have good separation of model/view/controller. Therefore, I'm updating it to use NSDocument and NSWindowController/NSViewController. On the whole,…
3
votes
1 answer

Why does "File's Owner" sometimes have a "view" outlet? Can I add my own?

When I create a new "Cocoa Class", of type NSViewController, and check "Also create XIB file for user interface", I get a blank xib file. Its "File's Owner" has an outlet "view" which is connected to the custom view. When I create a new "View" (xib…
Naha
  • 105
  • 7
3
votes
2 answers

How to disable the titlebar close, minimize and zoom buttons in an NSViewController on Mac OS X

How do I disable/enable the titlebar close, minimize and zoom (red, yellow and green) buttons in an NSViewController - preferably from Objective-C/Swift. I have searched the Storyboard properties but not found anything.
3
votes
0 answers

How to properly do dependency injection in an NSViewController

I am an iOS developer trying to put together a little OSX app. One thing I cannot figure out is how to properly inject dependencies in my viewControllers. This is my setup: NSWindowController | +- NSSplitViewController | +- NSViewController …
de.
  • 7,068
  • 3
  • 40
  • 69