Questions tagged [cocoa-bindings]
Cocoa bindings is Apple’s implementation of the Model-View-Controller design pattern for Mac OS X applications. It provides technologies that automate the synchronisation of domain data and the user interface elements that present them.
974
questions
1
vote
1
answer
29
views
Can you save the selection of a master-detail bound NSTableView?
I have a manager class for my data which is configured by two properties, one to set to a category and another to select items which correspond with that category. Based on that it will expose the ...
0
votes
1
answer
81
views
MacOS: How to update an AppDelegate property via editing a table view cell?
In my macOS app I’m trying to update an AppDelegate property by editing a Table View Cell.
I created a sample project (Table View example project with array controller) using tips from the answer to ...
0
votes
0
answers
107
views
How do I add my own properties to the Bindings Inspector in Xcode?
When editing a .xib in Xcode, I can select a view or other object, navigate to the "Bindings" tab in the Inspector, and bind its properties to properties of other objects. This is all well ...
-2
votes
1
answer
61
views
Cocoa Bindings on macOS
I learn Cocoa Bindings on macOS https://www.raywenderlich.com/921-cocoa-bindings-on-macos#toc-anchor-009,but I use xcode13 and swift5,I do this step by step,but The first step is to bind the array ...
7
votes
1
answer
188
views
Using INotifyPropertyChanged view models with Cocoa/AppKit bindings
I know this is pretty esoteric but hoping someone has a solution for me.
I have an application that started life as WPF, moved to UWP and now lives primarily as XF/MAUI and WinUI.
I'm wanting to port ...
1
vote
0
answers
46
views
What are the best practices for using objectIsForced with controls bound to a shared user defaults controller?
In the Preferences window of a macOS app on which I'm working, I have a number of controls that are directly bound via Interface Builder to the shared user defaults controller.
This works well, ...
0
votes
1
answer
56
views
NSTableView (or NSOutlineView) column hiding through contextual menu : a "no code" solution
I searched SO for the best solution to this question, found several clues, while not fully satisfying IMO. So I post below my no-code solution.
The goal is to have, as in Finder or other native ...
1
vote
1
answer
91
views
Subclassing NSImageView with the binding ability
I'm trying to animate the image change in NSImageView. It is a purely academic problem, and I'm staying within the restrictions of a macOS binding framework.
Please, consider the model:
class Model: ...
0
votes
0
answers
39
views
Can't update dictionary connected to NSDictionaryController
I'm playing around with cocoa bindings and table views, and I'm trying to create a simple 2 column table view where the keys are displayed in the left column and values in the right. When I try to add ...
0
votes
0
answers
51
views
How to wire up a custom view using NSViewController to a model?
I came across a problem where I see multiple approaches but I'm unsure which one to implement. Please consider this simplified example of a classical Cocoa MVC design:
My own custom graph view
...
0
votes
1
answer
213
views
Using Core Data and Cocoa Bindings in multiple storyboard scenes
I have a macOS app – not document based – that is using Cocoa Bindings, Core Data, and storyboards. The data model is straightforward...
List
Name
Players; to many relationship to Player
Player
...
0
votes
0
answers
90
views
Array Index out of range when adding row to NSTableView
I'm trying to create a coin flip simulation that will log the results of every coin flip in a NSTableView. However, when I go to insert a new row containing the result of the coin flip, I get a Fatal ...
0
votes
1
answer
83
views
NSTreeController with editable contents
I've got what (I would think) is an extremely simple case where an NSTreeController is bound to an array of root objects, each of which might have a few child objects. I am using an NSBrowser to show ...
0
votes
1
answer
56
views
Custom nspopupbutton title when using bindings and struct
How to display timezone identifier with bindings (using structs)? e.g. instead of Africa/xxx offset 3600 i want Africa/xxx only
class TimezonePopupButton: NSPopUpButton {
private var ...
1
vote
1
answer
229
views
How do I use Action Invocation in Xcode Interface Builder
I am having trouble getting the IB Action Invocation to work when using the Argument bindings. Can someone explain how this is meant to work. If I don't use the Argument binding then the binding ...
0
votes
0
answers
657
views
Swift: Thread-safe dictionary access via cocoa-bindings
I have a class and I need to bind a few NSTextFields to some values of a dictionary that will be changed by a thread.
class Test: NSObject {
@objc dynamic var dict : [String:Int] = [:]
let queue ...
1
vote
1
answer
42
views
NSArrayController binding details in 1:many:many model
I've got a simple program illustrating what I am trying to do in my real program. I've got a 1 to many relationship of 1 to many relationships, and I cannot get multiple selection editing to work ...
0
votes
1
answer
106
views
What Happened to Core Data Bindings?
I've been out of the loop for a while, but it used to be you could use Interface Builder to add an NSArrayController, set it's mode to Entity, and bind the managedObjectContext to the MOC of the ...
1
vote
1
answer
82
views
Is there a way to update an NSTextField label's stringValue without using an outlet?
So I'm new to Cocoa and Objective-C programming, but I've read enough to be able to modify this one program I'm working on almost completely to my satisfaction...with the exception of one particular ...
0
votes
1
answer
116
views
Binding visibility to arrayController selection
I have a NSTableView bound to a NSArrayController.
I have two buttons below the table that must be enabled only if there is an element selected on the table.
I select the buttons and bind ...
1
vote
0
answers
89
views
Bug in NSOutlineView/NSTreeController setSelectionIndexPaths?
Scenario:
NSOutlineView with Cocoa bindings on NSTreeController. NSOutlineview selection is bound to treeController.selectionIndexPaths
Add 3 items in the model
Set selection of these new items ...
0
votes
1
answer
71
views
Cocoa bindings only working one way (NSMutableDictionary)
I have a ViewController with a 'Note' object as an instance variable. This variable is set before the ViewController appears.
The Note object contains a customFields NSMutableDictionary<String, ...
1
vote
1
answer
246
views
Is it possible to programmatically bind two key paths setting continuous updates in Cocoa?
In a macOS Cocoa Application if I have two NSSlider objects, I can set the following binding programmatically:
@IBOutlet weak var firstSlider: NSSlider!
@IBOutlet weak var secondSlider: NSSlider!
...
2
votes
1
answer
412
views
Binding a NSPopupButton's selected identifier
I have several popup buttons whose selected tag is saved in the user defaults (by binding the selected tag in the Bindings inspector). Now instead of saving an integer I would like to save a string ...
1
vote
1
answer
189
views
NSPopUpButton - Weird behavior when populating dynamic content with Cocoa Binding
I'm trying to create a NSPopUpButton with dynamic contents, this is my design:
+-------------+
| None | <-- Static
| Last Item | <-- Static
|-------------| <-- Separator
| History: ...
0
votes
1
answer
154
views
Use cocoa bindings and threads
I have a few labels bound to a few variables that are modified in other threads via GCD.
Now I've read that cocoa bindings are not thread safe but my app is running fine (the UI updates when the ...
0
votes
0
answers
82
views
NSTableView with expandable/collapsable groups using Core Data & Cocoa Bindings
I have a data model stored in core data that is basically an array of items with a date.
They are currently displayed in a NSTableView using cocoa bindings via a NSArrayController.
What I'm trying to ...
0
votes
0
answers
36
views
Core Data - To Many relationship - Table bindings
I have a NSTableView with bindings.
Each row of the table is a Core Data Entity named Entry.
An Entry can have several CustomValue. Each CustomValue should be displayed in its own column in the Table....
0
votes
1
answer
228
views
Trying to bind a NSPopupButton's ```enabled``` property to a checkbox's state
Using cocoa bindings, I want that a popup button is enabled or disabled based on whether the checkbox is selected or not.
I am programatically adding checkboxes and popups to a stack view like this:
...
2
votes
2
answers
235
views
In my macOS App, I get the nasty "Unexpected outstanding background CATransaction" error and a crash, but only when running from Xcode
I have an Objective-C macOS application that has a window with essentially a NSTableView on the left and a details view on the right, in a NSSplitView. The window also has labels and other controls. ...
0
votes
1
answer
86
views
How to display two 1-m related CoreData entities in two NSTableViews using NSArray bindings
I have an entity 'person' and a 1-m related entity 'visit' defined in CoreData. Now I want to display and modify their values in related tables using NSArray controllers with COCOA bindings on MacOS
...
0
votes
0
answers
56
views
Binding @objc var [Double] array, setter never fired
I have a NSTableView, content bind to [Double] array in file's owner currentStaleValues:
@objc var currentStyleValues: [Double] {
get {
print ("getting currentStyleValues")
guard ...
2
votes
1
answer
496
views
macOS: Correct way of exposing Swift properties to Cocoa Bindings
I'm working on an existing Swift/Objective-C project on the Mac and I'm creating some UI in code. I enable a button based on the selection in a NSTableView that I manage without using ...
3
votes
0
answers
317
views
Swift macOS NSTableView very slow
I'm working in Swift (macOS) and have an NSTableView, the contents of which are bound to an NSArrayController. The tableView cells can set/edit the data using a mix of Strings and NSPopUpButtons ...
-1
votes
2
answers
588
views
Writing a matrix to a text file
So i have done how to read a matrix from a text file where the first line defines the elements, however my question is how would i do the opposite that would write to the text file. I would like it to ...
0
votes
1
answer
340
views
Cannot create programmatic Cocoa binding in swift
I am developing an application for macOS using swift. I have an Alarm object in my application that can be enabled or disabled. I have created a Cocoa binding from the alarm’s enabled property to a ...
-1
votes
1
answer
639
views
How to keep two properties in sync using bind(_:to:withKeyPath:options:)?
I want to keep two properties in sync with Cocoa bindings.
In my code, you can see that I have two classes: A and B. I wish to keep the message values in A and B instances synchronized so that a ...
1
vote
0
answers
184
views
Using NSTableView with cocoa binding and Realm
I am using NSTableView with cocoa binding.
The Array which is binding with my table is causing an issue when I tried to save it to Realm.
Error : Error Cannot add an object with observers to a ...
3
votes
3
answers
585
views
Singletons in Swift and Interface Builder
Background
I have a singleton class in my app, declared according following the one line singleton (with a private init()) in this blog post. Specifically, it looks like this:
@objc class Singleton {...
0
votes
1
answer
70
views
Prevent NSTableView from saving new row until user fills values
I'm working on a preferences window for my app, where the user can add and remove presets using NSTableView. A preset is defined as:
struct Preset: Codable {
var name: String
var value: Int
}
...
1
vote
0
answers
243
views
Create Interface Builder palette for exposeBinding
I followed my understanding of how to expose a property of an NSSlider subclass in Interface Builder but it is not showing up. I want to be able to bind the property in a viewcontroller through ...
-1
votes
1
answer
301
views
NSOutlineview with checkbox
I am looking to add checkboxes to NSOutlineview with bindings using as the basis this project https://developer.apple.com/library/archive/samplecode/SourceView/Introduction/Intro.html
How do I add ...
0
votes
1
answer
142
views
Cocoa Bindings, String value in Defaults bound to a Text Field. How can I programmatically read this string?
I have a cocoa binding between UserDefaults and a TextField setup via IB:
This works great, on every launch of the app the TextField will persist it's value
However, I also want to read this string ...
1
vote
1
answer
1k
views
Binding NSTableView to NSArrayController programmatically
I'm trying to bind an NSTextView to an NSArrayController in code, and have followed a few questions already asked on the subject: here, here, and here. I'm building a MacOS app using Xcode 9.2 and ...
2
votes
1
answer
624
views
Key-Value Observing (KVO) vs. Bind(_:to:withKeyPath:options:)
I'm confused about the difference between the Key-Value Observing method addObserver(_:forKeyPath:options:context:) and its accompanying observeValue(forKeyPath:of:change:context:) versus the bind(_:...
0
votes
0
answers
115
views
binding pop up button to relationship
I have 2 entities, Product and Manufacturer, they have a relationship in the data model
I have a ProductsAC - array controller for product entities and ManufacturerAC - array controller for ...
0
votes
0
answers
83
views
cocoa bindings to array controller crash
I have a Core Data Entity with a number of attributes, one is 'sku' and one is 'productDesc'. They are both string values.
I have an array controller for the Entity ProductAC
In my xib file I have 2 ...
1
vote
1
answer
487
views
How to use NSObjectController and Managed Object Context using Cocoa Bindings
Searched entire Internet but couldn’t find the modern solution for my problem.
I want to use NSObjectController in pair with Core Data through Cocoa Bindings and struggle to set it up properly. Worth ...
0
votes
1
answer
114
views
Binding to a property with Cocoa Bindings that is only available in a subclass
Coming from WPF the following issue was always an easy task:
I have a class called baseClass that has two subclasses called
subClassA and subClassB.
My View Controller has an array called
objects of ...
0
votes
1
answer
174
views
Cocoa Binding (Enabled) broken after updating to Swift4
I am trying to update my codes from Swift3.3 to Swift4.1 but encountering KVC error.
Swift4CocoaBindings[4639:2311856] [General] [<Swift4CocoaBindings.AppDelegate 0x604000000270> addObserver:<...