The statement of the question seems little abstract to me, so please read the details below.Since the time when C++ was the first choice Object Oriented Language for almost anything, we had a big problem of Multiple inheritance in C++ when two different implementations of same function declared or defined in a (abstract or concrete)parent class of the two, come to a common child class and create ambiguity, popularly known as the Diamond problem.C++ gave a solution : the virtual keyword, to be used while specifying the parent class(es) so that only one copy goes to the final child class being decided at runtime instead of compile time based on certain rules.Java tried to solve this by providing single inheritance and avoiding multiple inheritance completely.But then it lacked a feature where a class behaviour could be influenced by a bit and that may change in future or more behaviour may be added to it and we needed a way to encapsulate behaviour, then came the construct interface which had nothing but method declarations which each implementing class had to implement in their own way.Protocols in Objective C are more or less the same thing.However this approach has a major drawback, and this is where my question comes into picture.The drawback is, if a class has many subclasses implementing the same interface in the same way. The same code has to be written everywhere in each class.If it was all the classes, then the implementation could have been there in the parent class which gives the implementation.At max what can be done is to introduce a class with the implementation of the common method in between the current parent class and make all those classes inherit from it.But this can lead to lot of bugs if not done properly in a complex project.Scala provides Traits which not only serve as interfaces but can add full blown implementations for few of them that can be mixed with some classes that require it and removed when not.I haven't seen the syntax but I have heard that Ruby solves the same problem using something called as mixins.In case of Objective C, we have protocols but they have the same limitations as Java interfaces.So my question is, If I create a category of a class and  import it in any subclass of that class, Will the subclass get all those implementation methods? Also if I remove it, will it be synonymous to removing the trait inclusion declaration for a class?I might be wrong in any of my assumptions above, I am newbie when it comes to OOP design (and just got interested in FP).I would also appreciate any better solutions than this one.
Can Objective C categories serve the same purpose as Traits do in Scala?
design;objective c;scala;multiple inheritance
Importing (#import ...) an Objective-C category adds the methods defined in that category to all instances of the class on which the category was defined. Other than with traits which can be mixed into classes selectively a category extends the class on which it was defined once and for all.Also you can not create a standalone category and mix that into several different classes. A category is an extension for a specific class, similar as if you would add the methods to the class itself.Traits are like java interfaces but with implementation. Wether a trait can be mixed into a class depends not on the classes name but on the methods the class provides. If a class has the methods a trait needs, the trait can be mixed into that class.