cocoa-bindings

How to cancel saving preferences when using Cocoa bindings?

I'm just starting to mess with bindings. I've started implementing a preference dialog, binding some NSColorWell's to the shared defaults controller. That's working perfectly. My values are encoded and saved correctly. However, what's not working is canceling out of the dialog. If I cancel out, the values are still saved. It seems l...

Why are my images in my NSTableView faded out?

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...

lost library when recompiling Obj-C project

When I recompiled an old Obj-C project (a Cocoa app), the linker couldn't find some common library modules, including sin() and sysctl(). This project had been working in the previous version of Xcode. I am now using Xcode 3.1.2 in OSX 10.5. The error message was: Line Location Tool:0: collect2: ld returned 1 exit status Line Locat...

Basic Cocoa Bindings: Toggle a boolean from menu in IB

I'm just getting started with Cocoa Bindings and while I've read through much of the documentation, I'm still struggling to implement a basic feature, making me question wether I'm doing it wrong or perhaps it's just not possible via IB. Goal: Have a menu item called "Toggle visibility" toggle the state of a Boolean property in my appl...

NSFormatter used with a NSPopUpButton

I have a NSPopUpButton whose content values are bound to an NSArray of NSNumbers. The NSPopUpButton correctly displays the array of numbers in it's popup-menu. However, when I change the selected value, I receive a message: HIToolbox: ignoring exception 'Unacceptable type of value for attribute: property = "tempo"; desired type = NSNumb...

Tool for debugging KVO/Bindings in Cocoa

Is there any tool to log current observers of a given object, in the spirit of what "gdb info gc-roots" does? I found "gdb info gc-references" could do that (sort of) as a by-product of its original purpose, but that won't work with non garbage collected apps. Thanks! ...

NSManagedObjectContext and NSArrayController reset/refresh problem

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 ...

NSArrayController and KVO

What do I need to do to update a tableView bound to an NSArrayController when a method is called that updates the underlying array? An example might clarify this. When my application launches, it creates a SubwayTrain. When SubwayTrain is initialised, it creates a single SubwayCar. SubwayCar has a mutable array 'passengers'. When a ...

How does NSTableView modify the selection of NSArrayController via bindings?

Let's say I have the following situation: When I select different rows in the NSTableView, it magically updates the NSArrayController (PersonController) selection. How is the NSTableView doing this? Does it do something like this: - (void)bind:(NSString *)binding toObject:(id)observableController withKeyPath:(NSString *)keyPath optio...

Cocoa binding to single object from an array

I previously posted this question as a comment on a related thread thinking it was simple. That thread is here: http://stackoverflow.com/questions/670202/cocoa-binding-to-a-particular-item-in-an-array-controller/2082309#2082309 The questions relates to (and I'll more fully describe it here) a game I'm building to try and learn objec...

Doing something wrong with bindings, can't find out what

Hi, I've a mutable array that holds instances of a model object. That model object has several properties one being "name". I have no problems initialising or populating the mutable array. I've a window with a drawer. I added a table to the drawer, the idea being that the drawer would use the table to display several instances of the m...

Cocoa bindings: get old value upon change

I am writing a core data Cocoa application in which there are accounts and transactions (monetary). The account entity description contains a balance attribute. The transaction entity description has a relationship to an account. I need the application to update account balances when transactions have their accounts set or changed. For ...

iPhone Core Data: Do Transformable Attributes have to Transform to only Data?

I've been using transformable attributes in core data to transform complex objects like images and colors into raw data. I took this... The idea behind transformable attributes is that you access an attribute as a non-standard type, but behind the scenes Core Data uses an instance of NSValueTransformer to convert the attrib...

Aaron Hillegass _Cocoa Programming for Mac OS X_ Chapter 9 Question

In Aaron Hillegass' Cocoa Programming for Mac OS X, Chapter 9, the section called "Begin Editing on Insert", he explains how to do exactly that. The thing that confused me though, was that he did a bunch of other stuff. Here's the full code listing: - (IBAction)createEmployee:(id)sender { NSWindow *w = [tableView window]; // Try to end...

Validating input in NSOpenPanel accessory view

I would like to solicit additional information from the user during the NSOpenPanel but need to validate that information before the open panel completes. For example, I may want to allow the user to add a note about the file in the open panel selection but need to validate that that comment is not empty. I have an accessory view whose ...

[Cocoa] How to bind an editable TextField to a read-only property

Hello, Does anyone know how to prevent Cocoa binding to set values back to the bound property but still fires the default action selector? I am trying to bind a NSTextField to a readonly NSString property on my data object. My data Object is like ... @property(readonly) NSString* outCome; -(void)otherMethodsAffectOutCome; ... I bo...

Cocoa Binding, how to ask 'view' side to scroll to selection

Currently, I'm binding the NSArray to NSArrayController and then to a NSTableView, so the data and selection is working correctly, but seems I can't tell table view to scroll to selection from NSArrayController. Do I have to add an NSTableView outlet? I certainly can do that, but I'd try to see if there's a better way to avoid introduci...

NSObjectController confusion binding to a class property. Help!

Hi, I'm teaching myself cocoa and enjoying the experience most of the time. I have been struggling all day with a simple problem that google has let me down on. I have read the Cocoa Bindings Program Topics and think I grok it but still can't solve my issue. I have a very simple class called MTSong that has various properties. I have u...

NSMenuItem's value binding with BOOL

Hi, I am having some issues binding an NSMenuItem's "value" binding to a BOOL. I simplified the problem to this: 1) The menu item must call the action method that changes the value of the BOOL otherwise it doesn't work (i.e. if an NSButton calls a method that changes the value of the BOOL then the menu item won't update) 2) Even if ...

Cocoa data hierarchy and browser

I'm trying to implement something similar to the iTunes browser, to browser a simple database of Books. I have the following entities - Author, Genre and Book. I would like to display an author list and a genre list, which act to filter the main Book list. I have tried doing this in 2 different ways - modeled as: Author ( has many ) ...