Search code examples
iphoneobjective-cxcodeshared-librariessubclassing

SubClassing in iPhone objective c to share the common class files


I am very new to iPhone. I have developed two version of an application in iphone. Here i have used individual class implementations depends upon version features.

For example ' ListViewController' class have .h,.m, xib files. with the same name in two versions, but different in some part (little bit difference) code implementation.

In 1st 'ListViewController' version shows only a table view. In 2nd version 'ListViewController' shows tableview and a button just bello the table view, to set the reminders (alarm).

So just the difference in InterfaceBuilder *button* (AlarmButton) & in Code button action -(IBAction)SetReminder.

Now I need to put all the same classes in a library (Common folder) for the two projects v1&v2,

Now i need to implemente 'ListViewController' as common for both versions using subClassing.

How do I achieve that, any help or examples or link.


Solution

  • To share the same code between classes generally we use inheritance but there is a very cool feature added in objective-c that is category, find the tutorial link below: http://iphone-obsessed.blogspot.in/2010/05/tutorial-creating-class-categories-in.html

    Might Help...!!