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

前端 未结 2 785
小鲜肉
小鲜肉 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

提交回复
热议问题