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
6
votes
3 answers

How to check which NSViewController is active swift

I have an app with multiple ViewControllers and I need to check which ViewController is active at the moment in AppDelegate. For example, I'll create a timer that runs function that checks if the particular ViewController is active and if it is, do…
user4226616
6
votes
4 answers

dismiss nsviewcontroller swift doesn't work

That's the button action: @IBAction func readyPressed(sender: NSButton) { self.dismissController(Hardness) println(1) self.performSegueWithIdentifier("manual", sender: self) } When I press the button, println works, segue…
user4226616
6
votes
4 answers

How to open a new window with its own ViewController from AppDelegate in Swift

I have made a statusBar application with a drop down. I would like to open a settingsWindow from that dropdown. I have made the settings window with its own ViewController. The issue is that i can't figure out how to instantiate and show the…
Mads Gadeberg
  • 1,429
  • 3
  • 20
  • 30
6
votes
2 answers

How to instantiate NSViewController in Swift?

My current Swift code of var appBundle = NSBundle.mainBundle() let controller: ViewController = ViewController.init(nibName: "ViewController", bundle: nil) self.window.contentView.addSubview(controller.view) …
Team6Labs
  • 175
  • 3
  • 10
5
votes
1 answer

Mac OS X Cocoa single window application architecture

I cannot understand how to design an application in optimal way for a single window application to work in Mac OS X. I would prefer a single document - single window application (I'm not coding a utility application), but it is not clear where…
5
votes
2 answers

Cocoa Swift: Subview not resizing with superview

I'm adding a subview(NSView), here is my code: override func viewDidAppear() { self.view.needsDisplay = true let newView = NSView() newView.autoresizesSubviews = true newView.frame = view.bounds newView.wantsLayer = true …
user2924482
  • 8,380
  • 23
  • 89
  • 173
5
votes
2 answers

How to access NSViewController from app delegate?

In my macOS application I have menu items, which are replicated also in main UI. Application is consisted of main window with its delegate and single view along with its view controller. In app delegate I capture menu item click action, then I need…
Pablo
  • 28,133
  • 34
  • 125
  • 215
5
votes
3 answers

How to close window (NSWindowController) by hitting the ESC key?

Issue I would like the user being able to close a window by hitting the ESC key but I can't get it to work in this specific case, hitting ESC triggers an error sound (the "no you can't do that" macOS bloop) and nothing happens. Context I'm making a…
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
5
votes
0 answers

Switching View Controllers within a Container View programmatically - Swift and OS X

Using Swift 2.0 for an OS X (10.9) application, I wish to programmatically switch a view controller (a Tab View Controller) within a Container View to another view controller (i.e. replace the Tab View Controller with another View Controller). This…
richardjc
  • 89
  • 7
5
votes
0 answers

How do I use NSPageController on storyboard?

On the storyboard when I try to add a NSPageController, it comes out with it's own view. When I want to use a split view i can add a NSSplitViewController or just a split view. I prefer to use the SplitView inside a NSViewController. Is there…
Carlos Farini
  • 123
  • 2
  • 8
5
votes
2 answers

how to presentViewControllerAsSheet on OSX Mavericks?

It's a long story, but to cut it short; my first OSX app was written (on Yosemite) in Swift using a storyboard until I found out my (finished) app will not run on Mavericks. I need to run on Mavericks, so I have replaced the storyboard with NIBs. My…
DB1
  • 69
  • 5
5
votes
0 answers

Access an IBOutlet from another class in Swift

I'm new to Swift and Mac App. So I'm writing an Mac App today and I still confuse how to access an IBOutlet from another class after searching a lot. I'm using StoryBoard and there are two NSTextField path mirror in my ViewController. I have created…
Austere.J
  • 51
  • 2
5
votes
2 answers

Set representedObject on an NSViewController in a document-based OS X application

I am working on a simple OS X Cocoa application, in which the user fills in a form and the application performs some calculations that pop up in other fields. I started with the default Document-Based Application template on Xcode 6.3.2 (for…
wolfteeth
  • 86
  • 1
  • 8
5
votes
0 answers

Xcode 6 - Swift - Multiple views on a single-window storyboard cocoa app

Just last week I decided to dive into the world of Swift and Xcode development, and as of yesterday I am actively working on a new application. I have a lot of experience with Java Swing, but working with that is obviously a lot different than…
5
votes
1 answer

Navigation between NSVIewController

I am very new to MAC OSX app development. In my application I have three NSViewControllers, which are PracticeController, NoteController and QuestionController. I have to navigate to NoteViewController from PracticeController and QuestionController…
Juno
  • 347
  • 2
  • 11
1 2
3
27 28