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

Mac OS X Cocoa multiview application navigation

I've already spent 2 full days trying to figure out how to use NSViewControllers in order to create a multiview application. Here is what I do. I have 2 View Controllers and the MainMenu.xib's Window. I also have an AppController that is the…
Miky Mike
  • 341
  • 6
  • 17
5
votes
2 answers

Getting a NSViewController's View if it is a custom class?

I use the following code to get my View out of my controller: CollectionItemView *myView = [self view]; This works pretty well, but I get the warning Incompatible pointer types initializing CollectionItemView __strong with an expression of type…
hakkurishian
  • 266
  • 1
  • 3
  • 13
4
votes
2 answers

NSViewController & Interface Builder

I have a simple project which consists of a simple window with one view coming from a NSViewController (see https://i.stack.imgur.com/UAn6L.png ) The view is managed (+ linked, see screenshot) to my custom view controller object. I dragged a…
user1114537
4
votes
2 answers

How to call registerForDraggedTypes in NSViewController?

I have a MainViewController with a splitview in it. Next I have two viewcontroller to control each of the views in the splitview. I want to be able to drag and drop a file in one of those views. But I can't seem to get the dragging to work? There's…
ThomasM
  • 2,647
  • 3
  • 25
  • 30
4
votes
3 answers

How to handle keyboard events in subclass of NSViewController?

I am creating one cocoa application having wizard like structure. All dialogs are subclass of NSViewController. Currently I am not able get keyboard events such as keyDown and keyUp.. Please help me to solve this problem.... Thanks in advance....
Priya
  • 51
  • 1
  • 3
4
votes
2 answers

Any solution for Cocoa push/pop of view controllers?

Let me get this out of the way: I'm used to to UIKit, where you can push/pop view controllers to your hearts content. That just doesn't work on the Mac. With TwUI, this works extremely well on the Mac. For example, look at @joshaber's push/pop…
sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
4
votes
2 answers

Cocoa app not loading views or running code on High Sierra

I have an app on the Mac AppStore and many users have recently written to say it doesn't work on High Sierra (possibly 10.13.6, its hard to extract specific information from them). I managed to reproduce the issue on a friend's device, however I…
Max Chuquimia
  • 7,494
  • 2
  • 40
  • 59
4
votes
1 answer

How make custom view and over it's NSButton is clickable in macOS swift?

I've NSButton in NSView. The NSView has NSClickGestureRecognizer. Now I am able to get action from NSView that have NSClickGestureRecognizer. But the problem is NSButton is not able click. How can I solve this problem? Code: import Cocoa class…
user6298177
4
votes
1 answer

macOS application like Photos.app on macOS

I'm trying to create a macOS app like Photos.app. The NSWindowController has a toolbar with a segmented control. When you tap on the segmented control, it changes out the the NSViewController within the NSWindowController. What I have so far is an…
Mario A Guzman
  • 3,483
  • 4
  • 27
  • 36
4
votes
2 answers

Tabbing between NSTextFields with nextKeyView

I have a single NSViewController with the following layout, set using a storyboard: The nextKeyView outlet of each of the NSTextFields is configured to be the next NSTextField in the order presented on the screenshot. For example, I chose the…
4
votes
2 answers

Can't drag or move custom NSWindow

I create a NSWindowController and NSViewController using Interface Builder, And then, i removed the NSWindow's titlebar so that I can custom Window. i create a class subclass NSWindow And do following things in class. override var canBecomeKey: Bool…
J.Wu
  • 41
  • 5
4
votes
1 answer

Control a NSTabViewController from parent View

(I'm using storyboards and swift.) I currently have a NSWindowController which has a NSTabViewController as contentViewController. I am now trying to change the Tabs from the NSWindowController via code using let tabController =…
Mike Nathas
  • 1,247
  • 2
  • 11
  • 29
4
votes
2 answers

NSViewController not released

I have a question on the ownership of windows vs view controllers and when they're released. I created a test project, and only added one line of code to the NSViewController: deinit { print("ViewController Dismissed.") } Why isn't this called…
JoeBayLD
  • 939
  • 2
  • 10
  • 25
4
votes
1 answer

Access NSDocument from NSViewController and vice versa

What is the correct way to access the NSDocument subclass from its associated NSViewController subclass and vice versa? I have the following code that does the former, but it doesn't work when the view has loaded or when it moved to a window: var…
4
votes
1 answer

Modal sheet is not attached to window

I'm trying to call modal sheet inside my root window. I've have success with showing sheet but it is not attached to main window. I've read about similar problem: Window outlet is set (it is automaticly set by XCode) Visible at launch option is…
Vasily
  • 3,740
  • 3
  • 27
  • 61