cocoa-bindings

How to force-update Cocoa bindings?

爷,独闯天下 提交于 2019-12-07 04:10:56
问题 I'm using Cocoa bindings (as in Objective-C on the Mac) to display a relative date value using a value transformer. That is, my NSValueTransformer subclass converts an NSDate instance to NSString to display relative dates like "3 seconds ago", "2 minutes ago", etc. As you can see, these displayed values gets outdated as time progresses and thus will need to be refreshed somehow. I know I'll need to use a timer and then force the bindings to update so that the value transformer gets re

Cocoa Bindings - NSTableView - Swapping Values

你说的曾经没有我的故事 提交于 2019-12-06 16:30:19
Is an NSValueTransform subclass a good choice for displaying Core Data attributes into UI views displaying: A number string like (0,1,2,3,etc) into a string such as (Pending, Completed, Frozen, In progress, etc) A number string like (0,1) into a app-based image (red.png if 0, green.png if 1) Here's what Core Data displays for the two attributes, timer and status: Here is what I want to be displayed instead, without changing the values in Core Data: If not to use NSValueTransformer, in what other way is this possible? I do not want to see the data permanently converted, only for the benefit of

How to create a binding for NSApp.dockTile's

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:27:14
In IB it is easy to bind a label or text field to some controller's keyPath. The NSDockTile (available via [[NSApp dockTile] setBadgeLabel:@"123"]) doesn't appear in IB, and I cannot figure out how to programmatically bind its "badgeLabel" property like you might bind a label/textfield/table column. Any ideas? NSDockTile doesn't have any bindings, so your controller will have to update the dock tile manually. You could do this using KVO which would have the same effect as binding it. Create a context as a global: static void* MyContext=(void*)@"MyContext"; Then, in your init method:

Differences between NSTableView and NSCollectionView

谁说胖子不能爱 提交于 2019-12-06 12:11:38
问题 I'm trying to decide which path to take for developing my Snow Leopard app. First, I should preface with the obvious differences: NSTableView can have multiple columns of data for representing different parts of the same "element" of data (a row) where NSCollectionView can display a grid of data as well, but every row+column combo is its own element. For my purposes, assume I'm dealing with a single column. As far as I can tell, NSCollectionView items are NSView s which all must be of the

Cocoa bindings problem; bound table columns don't show any data, no errors in console

时光怂恿深爱的人放手 提交于 2019-12-06 10:43:31
I'm having trouble converting my Cocoa project from a manually-synched interface model to a bindings model so that I don't have to worry about interface glue code. I followed the CocoaDevCentral Cocoa Bindings tutorial to make sure that I had covered all the bases, but things aren't working correctly. I have a master-detail interface, but I'm having trouble even getting the master portion of the interface to work correctly. No data is showing up in the master column, even though I've set up the bindings model similar to how it is shown in the tutorial. I've made sure all my controllers and

NSDictionaryController doesn't seem to observe changes to content dictionary

烂漫一生 提交于 2019-12-06 10:41:49
问题 I must be missing something simple, but I am having some trouble binding a tableView to an NSDictionaryController. Here is a model of my current scheme: TableViewColumn --bindsTo-->DictionaryController.arrangedObjects.(value or key) --bindsTo-->someClass.someClassMember.aDictionary. I've tested the tableView by adding an entry to aDictionary on init, which is displayed correctly. But when another method produces an object that is then added to aDictionary, the TableView doesn't seem to update

How to use NSObjectController with Core Data?

一个人想着一个人 提交于 2019-12-06 10:00:12
问题 I have spent more than a day on trying to find a simple example of how to use an NSObjectController for binding along with core data. All examples are of NSArrayControllers with NSTableView bindings. How would you setup a simple NSObjectController with core data to automatically save and fetch data? Lets say you want to bind an entity with a string attribute to a text field, how would you do this? 回答1: Here are the basics in Interface builder. Drag over an nstextfield into a view (from the

Filtering a single-column NSTableView using NSArrayController

筅森魡賤 提交于 2019-12-06 07:21:48
问题 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. 回答1: I have uploaded a project,

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

人盡茶涼 提交于 2019-12-06 03:20:59
问题 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

How do I delete an entity when removing it from an array controller?

三世轮回 提交于 2019-12-05 18:53:28
I have an entity (e.g. Employee) in a managed object model that is related to two other entities (e.g. Department and Team). Both relationships are one-to-many (i.e. an Employee must have one Department and one Team, Teams and Departments have many Employees). The two may or may not overlap (e.g. a team might be made up of employees from HR, Accounting & I.T. or it might jut consist of several employees from the one department). Department <-->> Employee <<--> Team I have two NSArrayControllers providing data for two NSTableViews, a Department table and a Team table. Employees can move between