Does Objective-C support Mixin like Ruby?

Posted by hacksignal on Stack Overflow See other posts from Stack Overflow or by hacksignal
Published on 2010-03-21T07:21:37Z Indexed on 2010/03/21 7:31 UTC
Read the original article Hit count: 633

Filed under:
|

In Ruby, there's Modules and you can extend a class by "mixing-in" the module.

Module myModule
  def printone
    print "one" 
  end
end

Class myClass
  extend myModule
end

theOne = myClass.new
theOne.printone 
>> one

In Objective-C, I find that I have a set of common methods that I want a number of Class to "inherit". What other ways can I achieve this without creating a common class and deriving all from that common class?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about objective-c-2.0