On Jul 11, 2013, at 4:50 PM, Lee Ann Rucker <lruc...@vmware.com> wrote:

> 
> On Jul 10, 2013, at 11:26 PM, Kyle Sluder wrote:
> 
>> On Jul 10, 2013, at 11:18 PM, dangerwillrobinsondan...@gmail.com wrote:
>> 
>>> Hi all,
>>> 
>>> Is there an appropriate way to subclass NSViewController to return a custom 
>>> view class or is casting the return of view or loadView the only way?
>> 
>> I'm not following here. It's generally bad form to override a method for the 
>> sole purpose of changing its return type. Just cast the returned value got 
>> the appropriate type.
> 
> What I do a lot, in my own classes and NSFoo subclasses, is this pattern.
> 
> - (MyView *)myView
> {
>   return (MyView *)[self view]
> }
> 
> and an assert that it really is the right type is useful too.

So does it matter that the IBOutlet private ivar of NSViewController is NSView* 
?

> 
>> 
>>> Is it even worth using on OS X since there are so few built in methods? Is 
>>> it more practical to just load views from nibs without NSViewController?
>> 
>> NSViewController does correct memory management of all top level object in 
>> the job, including breaking retain cycles caused by Cocoa Bindings. It's 
>> also an NSResponder subclass, though it doesn't get inserted into the 
>> responder chain automatically.
> 
> Yes. Life is *so much simpler* when you let the Cocoa code handle nib memory 
> management. The code we tossed when NSViewController came along was not 
> pretty.
No doubt the memory management wit this would be a PITA.
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to