What's wrong with using a category on NSObject to provide a default protocol implementation?
- 阅读更多 关于 What's wrong with using a category on NSObject to provide a default protocol implementation?
问题 I've been looking for a way to use optional protocol methods and have clean code. In other words: 1: No respondsToSelector: calls all over my code 2. Should work for any method signature, so a category method on NSObject making the check and calling performSelector: is out (and NSInvocation has problems cooperating with ARC) 3: This solution, IMO, pretends to be universal but has all the drawbacks of 1 I eventually came up with this idea: @protocol MyProtocol <NSObject> @optional -(void