cocoa - How to implement a specific multiple inheritance scheme in objective-c -
i've following class scheme implemented in obj-c: class subclass of uiviewcontroller. classes b , c subclasses of a. need create class d has subclass of a, contains uitableview need uitableviewcontroller functionality too. question is, how solve problem? whats elegant way of doing this? i've ideas on how it:
1- make a subclass of uitableviewcontroller , overload loadview method on classes dont use uitableviews catch exeption thrown when se try load uitableviewcontroller without uitableview. (this solution seems me more hack solution!)
2- keep unchanged , implement uitabledelegate , uitabledatasource protocols in d. (this solution seems me more elegant first 1 i'm reemplementing uitableviewcontroller).
3- create uitableviewcontroller inside class d manage tableview on behalf of d.
4- make d subclass of uitableviewcontroller instead of , create data member of type inside d manage part of d's job.
what think best way it? transforming protocol not option.
thank you.
the uitableviewcontroller
class few things you:
it creates
uitableview
view, if haven't specified view other way (by using xib or storyboard or overloadingloadview
or assigningview
property directly). easy yourself.it prevents current input field being hidden behind keyboard when keyboard appears. can yourself. it's not terribly hard. apple documents process in “moving content located under keyboard” in text, web, , editing programming guide ios , there many q&as covering here on stack overflow.
it other incidental things listed in “overview” section of * uitableviewcontroller class reference*, of trivial implement yourself.
if you're using storyboard, allows define static table view cells in storyboard. feature of
uitableviewcontroller
can think of cannot replicate in ownuiviewcontroller
subclass.
if don't need #4, should use solution #2 (just make a
subclass).
if need #3, use solution #4. better factor functionality out of a
separate helper class z
, , give both a
, d
instance variable (or property) of class z
.
Comments
Post a Comment