How to avoid accidental overriding method or property in Objective-C

前端 未结 4 1447
轮回少年
轮回少年 2021-01-04 05:47

For instance, I subclassed UILabel and added a method or property called -verticalTextAlignment to align text vertically.
And in the future, if

4条回答
  •  难免孤独
    2021-01-04 06:16

    Prefixing your category methods are the safest way to avoid these conflicts in an every growing, non namespaced cocoa ecosystem.

    It's quite valid and reasonable that framework creators, open source developers and other individual developers should prefix their class methods.

    Quite often I write methods prefixed with my company initials, then continue with the method.

    - (void)JCMyMethodNamedSimilarToBaseClass;
    

提交回复
热议问题