In my application, I have a mainViewController that has a bunch of letter tile UIImageViews. You can pan 开发者_如何学Cthe letters around on this mainViewController to spell out words.
I also have popover viewcontrollers that contain letter tiles that you can drag out onto the mainViewController. Once the letter tiles are dropped onto the mainViewController, they need to have access to all the same methods that the letter tiles do that already exist on the mainViewController.
Currently, I create the letter tiles in the mainViewController and the popover viewcontrollers separately. Both the mainViewController and popover viewcontroller's parent classes are UIViewController.
I was wondering if in my situation, I should be declaring all letter tiles contained in my popover viewcontrollers in the mainViewController class, then have the popoverview controllers be a subclass of mainViewController?
If I should change it, can you please tell me why it would be better to?
Thanks!
Objective-C is famous for preferring delegation over subclassing.
I would rather use a datasource class that knows of all the tiles and their methods and use it in both controllers.
精彩评论