cocoa-bindings

Use NSArrayController with nested NSMutableArrays (Cocoa Bindings Question)

Hi, I have a NSArrayController with following Object: @interface AdressCard : NSObject <NSCoding> { NSString* name; NSString* street; NSMutableArray* tasks; } I have a simple GUI with an NSTableView to display the first two keys and I want to have a second NSTableView to display the content of the MutableArray (tasks) for...

What do these errors in the XCode Debugger Mean?

I have 2 errors in XCode and am trying to figure out what they mean. The 1st one: 2009-06-30 18:56:27.998 Spark[4584:10b] Error setting value for key path filterPredicate of object <NSArrayController: 0x1482c0>[entity: group, number of selected objects: 1] (from bound object <NSSearchField: 0x143f20> with object ID 1387 in Nib named...

How do I get the representedObject from a view in an NSCollectionViewItem?

I have a view that gets used in each of my CollectionView's items. I have an IBOutlet to the CollectionViewItem from my view and I have that hooked up in Interface Builder. I want to access a value from the representedObject (which is a Core Data object) in my view code. Here is an example of what I'm trying to do -- access a sequence...

NSWindowController circular dependency caused by bindings?

Suppose you have a window nib, owned by a NSWindowController which loads the nib. The NSWindowController has an IBOutlet bound (via Interface Builder) to a UI control on the window. Is it true that you can't dispose the window controller by releasing it because the binding causes a unbreakable circular dependency between the window co...

Can you manually implement Cocoa bindings?

I've had a crack at implementing bindings for my own NSView subclass. It works, but there are problems with retain cycles when binding to File's Owner from a nib file. After reading into it a little, I discovered that Apple had the same problem a few years back but have fixed it with some magic undocumented class (NSAutounbinder). There...

NSOutlineView and NSTreeController example

Hi Everyone, Please send me some links on how to use NSOutlineView with NSTreeController bindings without using core data. Thanks in Advance, BP ...

How do I draw a shape in Quartz Composer for every element in an NSArray?

I have an XML file that I have parsed and have put the information I want into several NSArray objects. I want to be able to draw them in a QuartzView (anything better?) to visualize the data. The arrays should all hypothetically contain the same amount of info. I want one array to represent the x axis and another the y. It took long...

Most elegant way to sync managed objects with controls on iPhone?

I'm trying to port an iPhone application from using SQLite to Core Data. Is there a way to sync managed objects directly with the controls that manipulate their values, without having a controller in the middle? Note: I CAN do it the hard way -- it's what I'm doing now; I'm looking for the elegant, easy, fast way. I'm paging through t...

How to use NSCollectionView and Outlets properly?

Hey there, I'm desperatley trying to connect controls of NSViews which will reside in a NSCollectionView using outlets. The collection view is feeded using an NSArrayController. I created the NSView in a seperate NIB file and in the implementation of NSCollectionViewItem I overwrote copyWithZone to load it: -(id)copyWithZone:(NSZo...

Cocoa bindings: combine fixed items with ArrayController bound items in an NSPopupButton

I'm trying to make a color chooser using an NSPopupButton, and at the bottom i'd like a separator and a "Custom…" option. Is it possible to load the colors from array, then tack the separator and "custom" item on bottom? if so, how? Thanks! ...

Cocoa bindings and KVC with CGColorRef

I'm trying to bind a CGColorRef on one of my objects to the "shadowColor" property of a CALayer. Unfortunately, I haven't been able to figure this out - it's probably something really simple! The CGColorRef is implemented as a property: @property (readwrite) CGColorRef labelShadowColor; My binding is straight forward too: [aLayer bi...

Odd problem using addObserver:forKeypath:options:context: in init method

According to Apple and numerous examples I've seen, there is no problem using KVO/KVC to observer yourself. Also according to those same sources, it's not a problem setting this up by using addObserver:forKeypath:options:context: in an object's init method, a la: - (id)init { self = [super init]; if (self) { [self addObserv...

Getting to the managed objects in NSTableView

I have an NSTableView bound to an NSArrayController, which is bound to an NSManagedObjectContext with one Entity. How can I programmatically set a property on the object currently selected in the table view? I tried doing it directly through [[[documentsController arrangedObjects] objectAtIndex:[tableView selectedRow]] setObject:[NSDate...

Automatic Key-Value Observing in Cocoa

As I learn more about KVO and KVC, I have become curious - How does NSObject provide automatic KVO when accessing setter methods? If I create a new object with an accessor named setName, how does an observer get notified when someon calls [obj setName:@"Mystery"]; Thanks for any feedback ...

KVC/KVO and bindings: why am I only receiving one change notification?

I'm seeing some quirky behaviour with Cocoa's KVC/KVO and bindings. I have an NSArrayController object, with its 'content' bound to an NSMutableArray, and I have a controller registered as an observer of the arrangedObjects property on the NSArrayController. With this setup, I expect to receive a KVO notification every time the array is ...

Table view not updating according to bindings

This is a very newbie question, and this is something I have done many times before, but there's something I'm missing this time. In my AppDelegate.h file I declare an NSArray and set it as a property: @interface AppDelegate : NSObject { NSArray *lines; } @property(readwrite, retain) NSArray *lines; @end And then in the AppDelegate...

Observing NSTreeController's bound CoreData entities for insertion/removal

I am creating my own bindable custom treeview. For that I would like to observe NSTreeController for updates to its items' to-many-relationships. NSTreeController is bound to CD managed object context. Every depth level has its own CD Entity with parent/children/isLeaf properties. I need to maintain same hierarcy in the view (and order o...

NSTableView with columns bound to different NSArrayControllers

i have NSTableView and two columns in it: NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"custId"] autorelease]; [column bind:@"value" toObject:arrC2 withKeyPath:@"arrangedObjects.custId" options:nil]; [table addTableColumn:column]; column = [[[NSTableColumn alloc] initWithIdentifier:@"totalGrams"] autorelease]...

Is there a way to use bindings with an editable NSSecureTextFieldCell in an NSTableView?

I have an NSTableView with several columns, one of which is set up to use an NSSecureTextFieldCell as its dataCell. I am using a properly configured NSArrayController to provide data to this table. The problem is that my secure text field does not want to work. It shows an appropriate number of dots for the strings that it holds, but it...

Cocoa application architecture on Mac OS X

I'm getting back in to Cocoa development on the Mac after a long stint doing iPhone work. My previous experience with Cocoa on the Mac has just been dinky little tools. I'm looking to build something serious. Looking at a modern Cocoa application like iPhoto (or Mail or Things or....) many apps use the Single-Window, Source-List based a...