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
9
votes
2 answers

Proper usage of NSViewController representedObject

I have a NSViewController managing a NSTableView and noticed that NSViewController has a representedObject property, however it isn't an IBOutlet and I'm not able to bound the dataSource of NSTableView to the representedObject property of…
Tony
  • 36,591
  • 10
  • 48
  • 83
9
votes
2 answers

NSWindowController and NSViewController

Probably a pretty simple question, but I can't get my head around it. I would like to create some sort of wizard: An NSWindow appears as a sheet from another NSWindow and should show three different NSViews one after another. I think I should create…
fabian789
  • 8,348
  • 4
  • 45
  • 91
9
votes
0 answers

validateMenuItem on NSViewController

Is it possible to have validateMenuItem work with NSViewControllers? The docs say NSViewController is a subclass of NSResponder so I would think it would participate in the responder chain, but I have never been able to get it to work. I can make…
jsd
  • 7,673
  • 5
  • 27
  • 47
8
votes
1 answer

Create a custom view using a nib and use it in a window

I have been struggling quite a bit with this problem and I can't seem to figure it out by myself. This is the situation: I want to have a custom Nib-based view, with its own ViewController. I then want to add this view to a window. Therefore the…
Besi
  • 22,579
  • 24
  • 131
  • 223
8
votes
3 answers

How to make embedded view controller part of the responder chain?

I am developing a Mac app using storyboards. I have a window that presents an NSViewController as its contents, which contains a "container view controller" that embeds an NSSplitViewController. The expected behaviour is for the…
Abstract-Sky
  • 309
  • 1
  • 12
8
votes
4 answers

How do I switch out Views in a Cocoa application?

So I'm beginning to learn how to use Cocoa. I think I've pretty much got it but I'm hung up on creating and switching views. I'm rewriting a game I made a little bit ago for practice. All I want is one window (preferably not resizable) and I want to…
David Garcia
  • 81
  • 1
  • 2
8
votes
3 answers

How to use NSViewController in an NSDocument-based Cocoa app

I've got plenty of experience with iOS, but Cocoa has me a bit confused. I read through several Apple docs on Cocoa but there are still details that I could not find anywhere. It seems the documentation was written before the NSDocument-based Xcode…
8
votes
2 answers

What is the CGSUpdateManager and why is it complaining?

I am working on my user interface, trying to navigate my data through a whole bunch of nested NSSplitViewControllers,NSTabViewControllers, etc. At some point or another I get these error warnings. I have no idea where they are coming from and where…
user965972
  • 2,489
  • 2
  • 23
  • 39
8
votes
1 answer

Best way to set up a NSViewController initialized with initWithNibName:bundle:?

i have a subclass of NSViewController that loads its view from a nib (with initWithNibName:bundle: and it is the file's owner of that nib). I need to do some initialization after the nib is loaded and i want my code to be the most compatible : In…
Johnmph
  • 3,391
  • 24
  • 32
7
votes
1 answer

Cocoa Listen to Keyboard command+up Event

I am working on a macOS app and I would like to handle a local hotkey event (command + up arrow key) in a NSViewController. Here's how I do it with Swift: override func keyDown(with event: NSEvent) { let modifierkeys =…
hklel
  • 1,624
  • 23
  • 45
7
votes
2 answers

Center window in screen

Is there any way to center a window in the center of the screen in OSX? I am using the code below but it changes just the size but not the position on screen. override func viewDidLoad() { super.viewDidLoad() let ScreenStart =…
SNos
  • 3,430
  • 5
  • 42
  • 92
7
votes
1 answer

acceptsFirstResponder in NSViewController and xcode 6 - Swift

Could somebody explain to me how I can set acceptsFirstResponder on a NSViewController in Swift and xcode 6? The program doesn't allow any overriding of the function and says it doesn't exist in the superclass but I can also not set it as a variable…
Ron
  • 1,047
  • 13
  • 18
7
votes
1 answer

NSTextView not properly resizing with auto layout

I have a simple layout, which consists of NSView and its subview NSTextView. NSTextView is programmatically filled with some text that spawns multiple lines. I tie everything together using auto-layout (all done programmatically). However, when…
yura
  • 1,474
  • 1
  • 12
  • 16
6
votes
3 answers

NSPopOver & NSViewController - Drag to resize

I am making a MenuBar app for which I am using NSPopOver. The problem is that NSPopover uses NSViewController as a contentViewController, whose size gets fixed. My requirement is to make the size of NSViewController flexible i.e just like…
Nikhil Lihla
  • 607
  • 6
  • 21
6
votes
0 answers

Present a View Controller Programmatically OS X

so maybe this is so easy and I'm being dense but.. I'm trying to open a view controller that is displayed on my main.storyboard programatically from my MenuBarController. The View Controller doesn't have any segues attached to it but I have given…
Jimmy Jam
  • 107
  • 1
  • 6
1
2
3
27 28