In Objective-C, how to prevent name collision in category methods?

前端 未结 2 786
小鲜肉
小鲜肉 2021-02-04 20:59

Some people have used prefixes to name their category methods in order to prevent possible name collisions with other external code, but I personally find that adding noise to a

相关标签:
2条回答
  • 2021-02-04 21:34

    In Objective-C doesn't exist namespace so the only way is to prefix your method.

    If don't want to prefix (I agree with you..it's ugly) you can the OBJC_PRINT_REPLACED_METHODS environment variable to YES to receive a warning if you method name collide with other existing method.

    set environment variable

    0 讨论(0)
  • 2021-02-04 21:46

    Nope. Prefixes are the way to do it.

    0 讨论(0)
提交回复
热议问题