cocoa-bindings

Filtering a single-column NSTableView using NSArrayController

佐手、 提交于 2019-12-04 12:17:45
I present a sheet with an NSTableView (one column), an NSSearchField and an NSButton ('Add'). What I want is to set the content of the table view to a list of strings. This list of strings is in an NSArray called list . This content should be filtered based on the content of the search field (if a string in list ) does not contain the content of the search field it is not shown in the table view anymore. I'm not familiar with bindings, can anyone help me out. I have uploaded a project , kindly check. A rough idea how to do is as: (however understanding is easier by seeing the project) Create

Refresh Cocoa-Binding - NSArrayController - ComboBox

半城伤御伤魂 提交于 2019-12-04 11:40:45
in my application I made a very simple binding. I have a NSMutableArray bound to a NSArrayController. The controller itself is bound to a ComboBox and it shows all the content of the NSMutableArray. Works fine. The problem is : The content of the Array will change. If the user makes some adjustments to the app I delete all the items in the NSMuteableArray and fill it with new and different items. But the binding of NSMutableArray <-> NSArrayController <-> NSComboBox does not refresh. No matter if I remove all objects from the Array the ComboBox still shows the same items. What is wrong here?

How to trigger an action from a NSTableCellView in view based NSTableView when using bindings

雨燕双飞 提交于 2019-12-04 07:54:58
I'm facing a problem with a view-based NSTableView running on 10.8 (target is 10.7, but I think this is not relevant). I'm using an NSTableView, and I get content values for my custom NSTableCellView through bindings. I use the obejctValue of the NSTableCellView to get my data. I added a button to my cell, and I'd like it to trigger some action when clicked. So far I have only been able to trigger an action within the custom NSTableCellView's subclass. I can get the row that was clicked like this, using the chain: NSButton *myButton = (NSButton*)sender; NSTableView *myView = (NSTableView*

Bind properties in Swift to NSTextFields

流过昼夜 提交于 2019-12-04 06:26:08
问题 I'm working on a unit converter written in Swift that will automatically display the updated units within the appropriate NSTextField s. For this example, if the user inputs minutes into the minutesField , the secondsField and hoursField should automatically update to display the converted values from the properties. Below is an example of the code in my view controller: import Cocoa class ViewController: NSViewController { @IBOutlet weak var secondsField: NSTextField! @IBOutlet weak var

NSManagedObjectContext and NSArrayController reset/refresh problem

佐手、 提交于 2019-12-04 03:44:11
问题 I'm having trouble getting my UI to reflect external changes (made by another process) to an sqlite data store. I have a fairly standard core data based NSArrayController / table view. My app gets notified that external changes have been made to the data, at which point I do a [managedObjectContext reset]; // brute force, but data set is small The problem is, doing this clears all data from the table. The array controller's arrangedObjects is also empty. I thought a subsequent

What's a good way to bind from a shared utility window and the frontmost document window?

眉间皱痕 提交于 2019-12-04 00:37:31
I have an application which allows for multiple NSDocuments to be open. In this application is a single utility window that contains some functionality that I want to apply to the frontmost document. I am trying to use bindings here, so the trick is how to cleanly bind the user interface of the utility window to the frontmost document. The goal is that then switching the frontmost document window will update the view in the utility window; controls that are bound to properties of the frontmost document's model would be updated appropriately when state changes in the document's model, etc. For

NSPopupButton in view based NSTableView: getting bindings to work

妖精的绣舞 提交于 2019-12-03 14:38:25
问题 Problem Description I'm trying to achieve something that should be simple and fairly common: having a bindings populated NSPopupButton inside bindings populated NSTableView. Apple describes this for a cell based table in the their documentation Implementing To-One Relationships Using Pop-Up Menus and it looks like this: I can't get this to work for a view based table. The "Author" popup won't populate itself no matter what I do. I have two array controllers, one for the items in the table (

Why are my images in my NSTableView faded out?

落花浮王杯 提交于 2019-12-03 13:45:18
To start, there's an NSArrayController ("Servers") whose content is an array of "server" objects. I also have an NSTableView with a column. The column is bound to Server's "arrangedObjects.status" property. I use a custom NSValueConverter to make that status into an image for the column's dataCell which is an NSImageCell . What I don't understand is why the images that show up in the column are correct, but consistently faded out. Just to test, I have the same image outside the table view for comparison and it draws fine. The colors in the images are not semi-transparent. Does the NSImageCell

How do you bind a storyboard view to a Core Data entity when using NSDocument?

北城以北 提交于 2019-12-03 08:05:57
I'm building an OS X app that uses core data, NSDocument, storyboards, and Cocoa bindings. My expectation is that the following occurs: An instance of MyDocument ( NSDocument subclass) is created. MyDocument creates a Core Data NSManagedObjectContext that represents the document's data. MyDocument instantiates an NSWindowController from the storyboard by its identifier. Within the storyboard, the window controller contains DocumentEditorViewController ( NSViewController subclass) which displays and edits the document. Within the storyboard, DocumentEditorViewController has an NSArrayController

UITableViewCell error - this class is not key value coding-compliant for the key [duplicate]

偶尔善良 提交于 2019-12-03 07:27:35
This question already has an answer here: Class is not key value coding-compliant [duplicate] 8 answers I'm getting the following error when I try to load a custom UITableViewCell from a xib file via UINib's instantiateWithOwner method. I've tried all of the other solutions I can find on here with no luck. The issue seems to be that when the xib file is opened up by UINib, it uses the super class UITableViewCell instead of my custom class, ContentPackCell. I have attached a screenshot from Interface Builder showing where I associated the xib with my class as well associating an Identifier.