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:

  1. it creates uitableview view, if haven't specified view other way (by using xib or storyboard or overloading loadview or assigning view property directly). easy yourself.

  2. 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.

  3. it other incidental things listed in “overview” section of * uitableviewcontroller class reference*, of trivial implement yourself.

  4. if you're using storyboard, allows define static table view cells in storyboard. feature of uitableviewcontroller can think of cannot replicate in own uiviewcontroller 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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -