Detect conflicting Objective C category methods

21 Nov
2009

ObjC’s concept of categories has some problems when you use it too much – name conflicts!

Best practice is to prefix your own private categories (as there are no name spaces).

And you should really do that – some iPhone Apps are rejected currently for using categories that override default code.

Set the environment variable OBJC_PRINT_REPLACED_METHODS to YES to see warnings when such name conflict happens.

Update: (comment from DaringFireball)

Overriding private methods in a category is far worse than calling them directly.

Everything in your process will get the overridden behavior of the private method and assumptions about side effects go out the window.

Related posts:

  1. Detect if an iPhone is jailbroken
  2. Fast and elegant delegation in Objective-C
  3. UIScrollView: detect if we are at bottom

Comment Form

top

Switch to our mobile site