cocoa-bindings

NSMatrix simple binding question

喜欢而已 提交于 2019-12-12 04:20:59
问题 I am trying a sample application in which I have taken following controls: i. NSMatrix (with 2 elements, serving as radio button) ii. Button (which when clicked generates action based on radio button selected) My questions are- In IB, can we bind each button cell of NSMatrix to a single bool variable, say- firstElementValue, such that when user selects first button cell in NSMatrix, firstElementValue is YES and when user selects second button cell in NSMatrix, firstElementValue is NO. or Is

How does updating NSTableView from this mutable array work in Cocoa?

邮差的信 提交于 2019-12-12 04:09:47
问题 In my application, I have an NSTableView which should contain a list of files. I have a button that is used to open an dialog and programmatically add files to this list. For some time, I could not get the table view to update when I was adding files, as I was using the following code: [self.newPackage.files addObject:fileURL]; It makes sense to me now that this doesn't work. As I understand it, the above line of code would be changing the mutable array "behind the controller's back." I was

IKImageView zooming controlled by an NSSlider

狂风中的少年 提交于 2019-12-12 01:35:15
问题 What's the best practice for setting zoom factor of an image within IKImageView via NSSlider? I was able to bind a slider either to zoom in OR zoom out action of an IKImageView. Obviously, what I'd rather see is a single slider controlling both those actions. Best, if image is refreshed after each change of the slider (continuously, even if a mouse button is not released yet). 回答1: This demo explains a lot: ImageKitDemo In particular, this snippet is what I was looking for: - (IBAction)

Cocoa bindings - get @sum for an attribute for all children

蓝咒 提交于 2019-12-12 00:36:41
问题 I've been trying to get this to work for a while now. In my Core Data model I have: Entity Company has a one to many relationship with Employee ( employees ) Company.employees Employee.age Using bindings I would like to show the sum of age for all employees when clicking on a Company in a tableView. I've tried variations of: @distinctUnionOfSets.employees.@sum.age , but can't get it to work. When I try the above I get the error message: [<_NSFaultingMutableSet 0x10019c430> removeObserver

Prevent NSTableView from saving new row until user fills values

倾然丶 夕夏残阳落幕 提交于 2019-12-11 17:23:29
问题 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 } These presets should be persisted to UserDefaults . My goal is to write as little code as possible, and what little is written should be generic code, so my project makes use of NSUserDefaultsController , NSArrayController and Cocoa Bindings. Seeing as array, string and integer types are available in

Remove correctly selected NSManagedObjects

我与影子孤独终老i 提交于 2019-12-11 17:19:55
问题 Look at this great screenshot and I think you can imagine what I could ask... screenshot http://a4.s3.p.quickshareit.com/files/screenshot_75d0fc54a05ec7eae3f410.png The players: to the right: the preferences-panel and a NSTableView to the left: main-window with a NSPopUpButton (under the NSMenu ;] ) The selected object of the popup is binded to one of these in the tableview. This ugly thing (what you can see there) appears when I remove the (in the popup selected) object from the tableview. I

How to make NSArrayController preservesSelection work for custom object?

无人久伴 提交于 2019-12-11 09:05:59
问题 I have a Cocoa app with a view-based table view bound to an NSArrayController with a list of custom Employee objects. The table view shows the list of employees. In a subview, the employee's details can be changed. Everything is set up, so that when an employee's details are changed, the table view contents are reloaded, showing the changes. So far, so good. Now NSArrayController has the ability to preserve the selected object across reloads via preservesSelection . For my custom Employee

How can an NSCell detect the model key path it's bound to?

别说谁变了你拦得住时间么 提交于 2019-12-11 06:36:18
问题 Imagine the following: You have an NSTableView with multiple columns. Each NSTableColumn is bound to the same NSArrayController (we'll call it myArrayController ). This array controller holds many instances of a model class. One column has an NSPopupButtonCell where selectedObject is bound to myArrayController.arrangedObject.somePropertyOfTheModel . The table gets properly populated. Q : How can an NSCell detect the model key path it's bound to? ( somePropertyOfTheModel in this example) I'm

Cocoa binding NSTableView within NSTableView

夙愿已清 提交于 2019-12-11 03:42:33
问题 I'm trying to display a NSTableView inside a NSTableView. This is for an iTunes-like albums/tracks view. So there's a list of 10 albums, each album has some tracks. I want to display the albums in the outer table view and the tracks for each album in the inner. The first NSTableView is bound to an NSArrayController. Each object in the array has its own "tracks" NSArrayController, but I can't figure out how to tell the 'tracks' NSTableView that its content comes from a property of the 'album'

Master-detail using bindings with TWO NSTableViews

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:42:39
问题 I have a list of objects displayed in an NSTableView (bound to an NSArrayController). When you select an object in that list I want to show a detail view in a second NSTableView. My object has an array property. I can't figure out how to wire the bindings for this. binding to NSArrayController's selection doesn't work, as that's a single object, and NSTableView expects to be bound to an array... 回答1: Create a second NSArrayController and bind its contents to the first controller using a