cocoa-bindings

NSTextView textDidChange/didChangeText not called for bindings

强颜欢笑 提交于 2019-12-05 18:09:14
I have a custom NSTextView implementation that automatically adjusts the font size so that the text fills the entire view. I overwrote didChangeText to call my font size adjustment method. Works great when the user is editing text, but didChangeText (and the delegate method textDidChange: ) are not called when the text view contents are set via bindings. The font adjustment code needs to run whenever the text is set/changes, not only when it's changed by the user. How can I detect all changes to the text in an NSTextView , even via bindings? Note: If there's a better way to have the text fill

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

冷暖自知 提交于 2019-12-05 16:50:39
问题 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

NSButton in NSTableCellView: How to find desired objectValue?

三世轮回 提交于 2019-12-05 15:22:08
I have a view-based NSTableView that is populated through bindings. My textFields & imageViews are bound to the NSTableCellView's objectValue's properties. If I want to have an edit/info button in my NSTableCellView: Who should be the target of the button's action? How would the target get the objectValue that is associated with the cell that the button is in? I'd ultimately like to show a popover/sheet based on the objectValue. Your controller class can be the target. To get the object value: - (IBAction)showPopover:(id)sender { NSButton *button = (NSButton *)sender; id representedObject = [

New Core Data object doesn't show up in NSArrayController arrangedObjects

随声附和 提交于 2019-12-05 13:17:03
When I insert a new object in a Core Data managed object context and shortly after that try to find this new object in the NSArrayController (which is connect with the managedObjectContext through binding), I can't find it. I do the creation and search in one method. My question now. How long does it take for a new inserted object to show up in the NSArrayControllers arrangedObject array? Update: Here is the code for inserting and fetching the new objects NSEntityDescription *entity = [[[self managedObjectModel] entitiesByName] objectForKey:@"EntityName"]; NSManagedObject *object = [

How to force-update Cocoa bindings?

老子叫甜甜 提交于 2019-12-05 09:43:31
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-executed and display the correct relative date. But the question is, how do I make these bindings to refresh

How do I share an NSArrayController between two nib files?

不想你离开。 提交于 2019-12-04 23:49:25
问题 I have an array of images, and two nib files. One nib file has a window that displays the images in an NSTableView. The other nib has a window that draws the array of images into an NSView, and also draws a highlight over the images that are selected. The array of images is controlled by an NSArrayController. I'm having trouble getting the two nibs to share the NSArrayController. I would have two separate NSArrayControllers bound to the same content, but I also want both nibs to share the

Differences between NSTableView and NSCollectionView

末鹿安然 提交于 2019-12-04 18:02:45
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 same dimensions. Also, unlike NSTableView , collectionview items are copied to the NSCollectionView

How to use NSObjectController with Core Data?

蹲街弑〆低调 提交于 2019-12-04 16:03:03
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? Here are the basics in Interface builder. Drag over an nstextfield into a view (from the object library) Drag over a nsobjectcontroller (likewise) Open the bindings inspector. Option-Cmd-7 or View

NSDictionaryController doesn't seem to observe changes to content dictionary

拜拜、爱过 提交于 2019-12-04 15:54:09
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 or even know that aDictionary now has two entries. I've tried everything I can think of. I am not

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

风格不统一 提交于 2019-12-04 13:05:16
问题 This question already has answers here : Class is not key value coding-compliant [duplicate] (8 answers) Closed 6 years ago . 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