I'm sure what I'm trying to do is not that difficult but I've been pulling my 
hair out for a while now on this problem.

I have an application whose model could be updated without the user directly 
doing anything.  So bindings seems like the perfect fit b/c the interface will 
reflect these sorts of changes when they occur.  But I can't seem to get 
updates in my model to appear in the interface.  My model is an NSMutableSet 
that contains NSMutableDictionaries.  I then have a NSTableView with several 
columns.  I want each column in the table to display a value from each 
NSMutableDictionary.

@interface MyController : NSObject 
{
        NSMutableSet *myset;
}

//I initialize the NSMutableSet in this method.
- (void)awakeFromNib;

//Setter and Getter to ensure KVC compliance.
- (void)setMyset:(NSMutableSet *)set;
- (NSMutableSet *)myset;

//This method is here for testing.  A button in the UI is connected to the 
method.
//When executed this method creates a new NSMutableDictionary.  Adds some 
key/value
//pairs to it then adds the NSMutableDictionary to the NSMutableSet (myset).
- (IBAction)addValueToSet:(id)sender;


In Interface Builder I have dragged out an NSObject and set its type to be 
"MyController".  I then dragged out an NSObjectController and set its "Content" 
connection to the MyController object.  I then dragged out an NSArrayController 
and bound its Content Array binding to the Object Controller with a Controller 
Key of "selection" and a Model Key Path of "myset".  I also set the 
NSArrayController's Class Name to NSMutableDictionary since that is what is 
held by my NSMutableSet.  I setup a NSTableView in my application's window and 
then bound its first table column's "Value" binding to the NSArrayController 
using "arrangedObjects" as the Controller Key and "Caption" as the Model Key 
Path.  "Caption" is the key to a key/value pair in the NSMutableDictionary that 
is held by the NSMutableSet (myset).

In the addValueToSet: method I have the following code:

- (IBAction)addValueToSet:(id)sender
{
        NSString *newString = @"New Value";
        NSMutableDictionary *dict = [[[NSMutableDictionary alloc] 
initWithCapacity:1] autorelease];
        [dict setValue:newString forKey:@"Caption"];
        [myset addObject:dict];
}

When I click the button in my interface nothing happens.  I know the 
addValueToSet: method is being called however I would expect the interface to 
update based upon my updating the model.  Can anybody tell me what I'm doing 
wrong?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to