Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

darthtroll

macrumors newbie
Original poster
Aug 24, 2010
17
0
So I've got this UIView subclass that delegates methods from UIPickerView and UITableView etc...is it a bad programming practice in Coca to subclass this subclass?

Would my subclass also need delegate methods (assuming the logic isn't being changed)? In other words, is it mandatory? I'm planning on using about 5 different views across my tableViewController and I was debating having one ginormous class that has all the layout logic layed out and a bunch of "if" statements to decide the right methods to call for the 5 views.

OR I can create just a class that has all the layout logic and subclass that for different methods that should be called. What is the best and/or common practice?

Darthtroll
 
Why is your view acting as a controller. Normally objects in your controller layer would be the delegate to other views...
 
Apologies, I meant UIViewController subclass.

OK. Well normal subclassing rules apply. If you don't know what these are then stop programming and go and find out: this is a core piece of knowledge you need to have. In short any method you don't override in your subclass will automatically be inherited from the superclass.
 
While Cocoa programmers often don't create as deep a class hierarchy as in some other languages/APIs, that doesn't mean you can't subclass at all. If it means you write less and/or more readable code, go ahead and subclass :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.