Objective-c - Purpose of categories and protocols

后端 未结 5 1092
余生分开走
余生分开走 2020-12-15 01:50

I\'ve been reading up on Objective-c Protocols and Categories and both seem rather pointless to me. They\'re both used for adding things to the program in some funny way ins

5条回答
  •  长情又很酷
    2020-12-15 02:13

    Categories can be used to add functionality to existing classes, such as all the NS... classes. You can not add code to these directly.

    Protocols are used to specify that a certain class actually does something, when you call a method in the protocol.

提交回复
热议问题