Re: Setting available keys in NSController programmatically
Re: Setting available keys in NSController programmatically
- Subject: Re: Setting available keys in NSController programmatically
- From: Sean Gilbertson <email@hidden>
- Date: Fri, 17 Dec 2004 14:54:57 -0600
I actually ran across this last night before I went to bed, but didn't try it -- I just left the browser up and went to sleep. So anyway, I have tried it now and it works:
- (void)awakeFromNib {
/* .. */
[instance addObserver:_controller
forKeyPath:@"authors"
options:nil
context:NULL];
[_controller setContent:instance];
[_arrayController bind:@"contentArray"
toObject:_controller
withKeyPath:@"selection.author"
options:nil];
[_column bind:@"value"
toObject:@_arrayController
withKeyPath:@"arrangedObjects.lastName"
options:nil];
[_otherColumn bind:@"value"
toObject:@_arrayController
withKeyPath:@"arrangedObjects.bookName"
options:nil];
/* .. */
}
- (void)applicationWillTerminate:(NSNotification*)notification {
/* .. */
[_otherColumn unbind:@"value"];
[_column unbind:@"value"];
[_arrayController unbind:@"contentArray"];
[_arrayController release];
[_objectController release];
/* .. */
}
Notice that I set up (and own) all my controllers in code, not in the NIB file. The controller no longer gets multiple retains, and my array/object (authors/instance) do reach dealloc. Notice that since Controller never reaches dealloc, and to avoid cyclical retains/releases, I had to create another class ("instance") to hold the data ("authors"). The docs for applicationWillTerminate state that cleanup should be done there, but is there really no way to get my default controller to go into dealloc? I'm guessing it has something to do with instantiating it in the NIB file, but I don't think I can really avoid that. What are my options?
> On Dec 17, 2004, at 8:46 AM, Sean Gilbertson wrote:
>
> >
> > In IB, you can set the keys an NSObjectController "exports." How
> > can I do this in code? Please reply to my address, as I get this list in
> >a digest.
> >
> >--
> >Sean Gilbertson
> >IT Systems/Software Developer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden