Re: NSViewController subclass return type
Re: NSViewController subclass return type
- Subject: Re: NSViewController subclass return type
- From: Quincey Morris <email@hidden>
- Date: Thu, 11 Jul 2013 01:01:10 -0700
On Jul 10, 2013, at 23:26 , Kyle Sluder <email@hidden> wrote:
> 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.
The trouble is that a cast is (generally) a bug waiting to happen, because it masks the type being cast from. There's really no unobjectionable solution, so it's a matter of preference which good form gets violated.
On Jul 10, 2013, at 23:58 , Tom Davie <email@hidden> wrote:
> Except that view is a read/write property, and this is a type error, because of this situation:
>
> UIVCSubclass *s = [[UIVCSubclass alloc] init...];
> UIViewController *vc = s;
> [vc setView:[[[UIView alloc] init] autorelease];
It's not a practical problem for NSViewController, because the view is normally only set at loading time, and there's no verification of the view class at that time anyway. In the unlikely event that code like this needed to exist, then it would make sense to override the "view" property setter and check the view class at runtime.
_______________________________________________
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