Re: Subclassing a View Controller in a Storyboard
Re: Subclassing a View Controller in a Storyboard
- Subject: Re: Subclassing a View Controller in a Storyboard
- From: Kyle Sluder <email@hidden>
- Date: Wed, 04 Sep 2013 07:47:35 -0700
On Sep 4, 2013, at 7:02 AM, Matt Neuburg <email@hidden> wrote:
>
> On Sep 4, 2013, at 4:13 AM, email@hidden wrote:
>
> What you're doing has a lot of bad smells:
>
> * If I'm only going to call instantiateViewController, why am I using a storyboard here at all? If I use a .xib file instead, I can tell the view controller what .xib to use at its view nib, regardless of it's class.
Storyboards give you access to static table view cells.
>
> * If the only difference between this object and that one is self.pMusicCategory, why am I bothering to subclass?
You still need to subclass to have a music category property.
> Why not set the music category of the instance as soon as it is created?
In this example, it is a constant.
> Gosh, if I weren't using a storyboard, I could even have a designated initializer that takes a music category as a parameter.
You could do that, but OP is using storyboards. In that case, the proper way to pass that info is in -prepareForSegue:.
>
> * Even if you must use a storyboard, you can set an arbitrary variable in the resulting instance, using the user-defined runtime attributes.
You can't use symbolic constants here, and it’s shoved into some little-used menu. User-defined runtime attributes are a smell.
>
> * If all else fails, implement loadView.
Why do this when -viewDidLoad is expressly provided for setting up a view after it’s been loaded? OP does not need to customize the loading process.
In short, none of your advice is appropriate.
--Kyle Sluder
_______________________________________________
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