Adding the same category to multiple classes

后端 未结 6 609
陌清茗
陌清茗 2021-02-07 03:25

I have an Objective-C category that I\'d like to add to multiple classes without duplicating the code contained in the category. I simply want to add the same methods to multipl

6条回答
  •  借酒劲吻你
    2021-02-07 04:18

    It sounds kind of like you want something like a ruby module. I don't know of any way to do such a thing in objective-c. You could make a protocol and make each of your classes conform to your protocol, but that doesn't solve the problem of sharing implementation of the methods.

    Check out this question, it might provide some more insights.

提交回复
热议问题