Does Objective-C support Mixin like Ruby?

后端 未结 4 1865
一向
一向 2020-12-24 12:53

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
         


        
4条回答
  •  再見小時候
    2020-12-24 13:19

    This is my take on implementing Mixins in Objective-C, without using the Objective-C runtime directly. Maybe it's helpful to someone: https://stackoverflow.com/a/19661059/171933

提交回复
热议问题