-1

I have a class written in Objective-C and I want to have another similar one. Except for few details. Is there any smart way of copying class implementation and making another class? I'd like to change few things, but ctrl+c + ctrl+v sounds so unintuitive.

Regards

PS. edit: I have multiple classes to implement, also I'd like to have neat solution for future.

thedazed
  • 81
  • 1
  • 7
  • 1
    You can use `Inheritance` check out this https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html – Mohit Aug 27 '14 at 10:46
  • http://www.tutorialspoint.com/objective_c/objective_c_inheritance.htm and http://agilewarrior.wordpress.com/2012/03/20/simple-objective-c-inheritance-example/ – Mohit Aug 27 '14 at 10:47

2 Answers2

2

Use class inheritance.

Implement class A with the common functionality

Derive classes B and C from A to add functional differences.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
0

Take a look at Classes Inherit from Other Classes.

If you like to simply add a method without subclassing, see Categories Add Methods to Existing Classes. But be aware what you shouldn't do with categories!

If you like to change values, add appropriate properties to the interface declaration.

Community
  • 1
  • 1
Norbert
  • 4,239
  • 7
  • 37
  • 59