This implies that you’re not manipulating your “myListRoot” property in a way 
compliant with Key-Value Observing.

Just manipulating the instance variable will not post KVO notifications for the 
property.  You need to manipulate the property (for example, by working with 
the proxy NSMutableArray returned by [self 
mutableArrayValueForKey:@"myListRoot"]) in a KVO-compliant fashion for bindings 
to notice your changes to it.

In other words, I think your -awakeFromNib code probably looked like this:

   - (void)awakeFromNib {
       myListRoot = [[NSArray alloc] initWithObjects:foo, bar, baz, nil];
   }

It should look like this:

   - (void)awakeFromNib {
       [[self valueForKey:@"myListRoot"] addObject:foo];
       [[self valueForKey:@"myListRoot"] addObject:bar];
       [[self valueForKey:@"myListRoot"] addObject:baz];
   }

The reason it may have worked in -init is that when your bindings set up KVO 
for the "myListRoot" property, they may have retrieved its initial value.

Also, just on a stylistic note, I wouldn't name a property something like 
"list" in a Cocoa application to represent a collection presented in an outline 
view; Cocoa's controls are "tables" and "outlines" rather than "lists" and 
"trees."  (NSArrayController and NSTreeController use the terms they do because 
they're about the structure of the data presented, not the view; you can bind 
either an NSOutlineView or an NSBrowser to an NSTreeController, for example.)  
Ideally I'd name the property something more related to what the data actually 
represents, e.g. "people" or "products."

 -- Chris


On Oct 12, 2010, at 6:52 AM, Hrishikesh Murukkathampoondi wrote:

> I moved the code populating myListRoot to the "-init" method of MyDocument.m 
> and now it works. I was earlier populating it in "-awakeFromNib".
> 
> I am so tried putting it back in -awakeFromNib followed by a call to 
> [mOutlineView reloadData] - but this did not work. 
> 
> So I have my NSOutlineView showing me the text stored in my data root tree. 
> But cant explain the above behavior.

_______________________________________________

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