Re: NSViewController subclass return type
Re: NSViewController subclass return type
- Subject: Re: NSViewController subclass return type
- From: Lee Ann Rucker <email@hidden>
- Date: Thu, 11 Jul 2013 03:37:13 -0700 (PDT)
- Thread-topic: NSViewController subclass return type
> So does it matter that the IBOutlet private ivar of NSViewController is NSView* ?
Not if MyView is a subclass of NSView, and I only bother with the myView accessor if I specifically need to reference MyView methods.
----- Original Message -----
From: email@hidden
To: "Lee Ann Rucker" <email@hidden>
Cc: "Kyle Sluder" <email@hidden>, "List Developer Cocoa" <email@hidden>
Sent: Thursday, July 11, 2013 1:33:13 AM
Subject: Re: NSViewController subclass return type
On Jul 11, 2013, at 4:50 PM, Lee Ann Rucker <email@hidden> wrote:
>
> On Jul 10, 2013, at 11:26 PM, Kyle Sluder wrote:
>
>> On Jul 10, 2013, at 11:18 PM, email@hidden 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 (email@hidden)
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:
This email sent to email@hidden