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
34
votes
1 answer

NSViewController User Interface State Restoration

Summary: What's the proper way to save/restore the state of an NSSearchField in my NSViewController using the built-in user interface preservation mechanism of Cocoa? Details: I'm working on my first macOS app and I'm having a little trouble with…
rmaddy
  • 314,917
  • 42
  • 532
  • 579
33
votes
1 answer

NSWindowController/NSViewController "Presentation" setting in Storyboard

What exactly does the Presentation option(in Attribute Inspector) do in StoryBoard for Cocoa. It gives two options to select from Single Multiple P.S When googled the title, results are related to powerpoint presentation
Kaunteya
  • 3,107
  • 1
  • 35
  • 66
25
votes
2 answers

NSViewController and multiple subviews from a Nib

I'm having a difficult time wrapping my head around loading views with Interface Builder and NSViewController. My goal is to have a view which meets the following description: Top bar at the top (like a toolbar but not exactly) which spans the…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
23
votes
2 answers

Swift + NSViewController background color (Mac App)

I am trying to change the background color of my View. The View Controller class is NSViewController type. How this can be done? In iOS UIKit (UIViewController) there is self.view.backgroundColor, but NSViewController doesn't have that. And second…
Rohirm
  • 249
  • 1
  • 2
  • 5
16
votes
4 answers

Handle close event of the window in Swift

How to handle close event of the window using swift, for example, to ask "Are you sure you want to close the form?" The form will be closed in the case "yes" and not closed in the case "no". Showing message box is not a problem for…
Evgeniy
  • 403
  • 1
  • 8
  • 18
16
votes
2 answers

Cocoa application architecture on Mac OS X

I'm getting back in to Cocoa development on the Mac after a long stint doing iPhone work. My previous experience with Cocoa on the Mac has just been dinky little tools. I'm looking to build something serious. Looking at a modern Cocoa application…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
15
votes
2 answers

How to configure a WKWebView to fill an NSWindow?

I have a small prototype application developed in Swift with XCode 7.2. The application was created as a Cocoa document-based application with a storyboard. As such, the project contains AppDelegate.swift, Document.swift and Main.storyboard, all of…
Rob Smallshire
  • 1,450
  • 1
  • 15
  • 22
15
votes
5 answers

Non-resizable window swift

I have a NSViewController named Hardness, and I need not to let user resize it. Of course, I can just resize it back every time the users tries, but is there any way just not to let user open a window to full screen, or to stretch the window?
pomo_mondreganto
  • 2,028
  • 2
  • 28
  • 56
14
votes
2 answers

How to use autolayout with view-based NSTableView when view are provided by an NSViewController?

I have made the following example app to illustrate my question. The left view is a place holder view (added in Interface Builder). When the App loads I add a subview managed by a NSViewController. The NSViewController draws the different coloured…
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
13
votes
1 answer

how do I get WKWebView to work in swift and for an macOS App

before this get's shot down for being a duplicate, it isn't. Pretty much every question on WKWebView here is about WKWebView in iOS Apps, not macOS Apps, with the difference being pretty much just the UIViewController interface being implemented…
Ozymandias42
  • 131
  • 1
  • 1
  • 5
13
votes
4 answers

How to add NSViewController to a responder chain?

I'm having hard time understanding and finding info about how to make NSViewController accept key and mouse events. I read somewhere that in order to register these events in NSViewController it should be added to a responder chain, but I can't find…
Eugene Gordin
  • 4,047
  • 3
  • 47
  • 80
12
votes
2 answers

Swift: Switch between NSViewController inside Container View / NSView

I want to achieve a really simple task—changing the ViewController of a Container View by pressing a button: In my example the ViewController1 is embedded into the Container View using Interface Builder. By pressing the Button ViewController2 I…
ixany
  • 5,433
  • 9
  • 41
  • 65
10
votes
2 answers

QuickLook consumer as a delegate from an NSViewController

I am having some problems implementing QuickLook functionality from a table in an NSView. The limited documentation on QuickLook really doesn't help at all. After reading through the Apple Docs (which are geared heavily towards custom generators and…
Hooligancat
  • 3,588
  • 1
  • 37
  • 55
10
votes
3 answers

NSViewController disable resize when presented as Sheet?

So I am presenting an NSViewController as a sheet of a window that has resize disabled. The view controller that is presented as a sheet can still be resized. How do I disable resizing of a NSViewController?
user1001506
10
votes
1 answer

Reusable NSView from .xib

In several parts of my application, I need a control where a user can enter a password. The password field is secure, however I want the user to have the ability to switch the field to plain text and check for typos, etc. The password field itself…
TheNextman
  • 12,428
  • 2
  • 36
  • 75
1
2 3
27 28