412 questions
2 votes
1 answer
76 views
Swift: Protocol Constraint on iVar + Equatable
Context Consider this protocol and class in Swift 5.9: protocol SpinnerHosting: AnyObject { var spinnerItem: SpinnerItem { get } } final class MyViewController: NSViewController { var ...
0 votes
2 answers
69 views
Why this swift code does not show up line and the animation?
Why is the MyViewController does not get's shown in the window although the it's stated in the contentViewController: MyViewController() ? I'm not on storyboard or XIB and I don't wanna use a nib file....
1 vote
1 answer
41 views
Why this swift code does not show up the textfield?
The code should just view a "Hello, World!" in the window. The window appears but the text is not showing. Why is that? I can see that the window.makeKeyAndOrderFront(nil) even orders the ...
0 votes
0 answers
45 views
NStableView does not react to notification @"NSTableViewSelectionDidChangeNotification" call on Ventura
I used an Objective-C method to get the managedObjects on Xcode 9.2. Today I have a new iMac with Xcode 14.3 and the method is not called. -(void)awakeFromNib { _center = [NSNotificationCenter ...
0 votes
2 answers
2k views
Using SwiftUI Charts in macOS Foundation App
I have a Foundation macOS App written in Swift. I'm trying to use SwiftUI Chart View in NSViewcontroller (tutorial here) but it's seems import Charts doesn't recognized and I obtain the error Cannot ...
0 votes
1 answer
281 views
Getting the NSWindowController of an NSWindow returns nil
I want to be able to retrieve the NSWindowController of a specific class of window opened by my app, returning the customer class of that window. The code walks through the window list, looking for ...
1 vote
2 answers
498 views
How do I show a new/additional NSViewController in swift macOS App with no modal
step1. I new a project in Xcode 13.2.1 with macOS App, swift and storyboard step2. The default NSViewController named InitialViewController. I add a button named open. step3. I add a NSViewController ...
0 votes
0 answers
58 views
NSController calling function in NSView
I am trying to make NSViewControler work with NSView. I can't get myView to call any function in myView(NSView). myView?.myFunctionName does not work and for NSView I get a nil error when I try set ...
0 votes
0 answers
44 views
NSViewController subclass object is loaded, but its widgets are not loaded into its NSView
I have created a custom view that is intended to be loaded in some different windows. ActionWidgets is a subclass of NSViewController, complete with its own xib file and its own widget contents. In a ...
0 votes
0 answers
60 views
NSView drawrect flicker
I am using NSView as a digital display screen. When I invoke [display setNeedsDisplay:YES] The view's drawrect function seems to entirely clear the view before redrawing it contents. This results in ...
0 votes
1 answer
334 views
How to make `NSViewController` a `@MainActor` and have it implement `NSMenuItemValidation`
I've a custom NSViewController subclass that implements the NSMenuItemValidation protocol. That works just fine, until I mark the view controller as @MainActor. I believed Apple marked all view ...
0 votes
1 answer
74 views
Question about segue and NSViewController
I am new in Swift and have a question. I have ViewController for my customer with a included a tableView that list their past invoice. When I double click on an invoice, it open the Invoice ...
-1 votes
1 answer
107 views
How do I change viewControllers in swift with Foundation Xcode
I am trying to programmatically switch to another viewController scene when a certain event happens in Xcode for a MacOS app but am having trouble. The second view controller is in the same storyboard ...
0 votes
2 answers
415 views
How to implement `viewDidAppear` without NSViewController?
There is a method in NSViewController called viewDidAppear. The docs say: This method is called after the completion of any drawing and animations involved in the initial appearance of the view. If ...
1 vote
2 answers
1k views
viewDidLoad() not called
Either there is something weird in my project (Mojave, XCode10) or I am missing something very basic. This is my whole code: import Foundation import Cocoa class ViewController: NSViewController { ...