What use cases are there for defining a new root class?

前端 未结 4 430
傲寒
傲寒 2020-12-10 04:12

We know that in Objective-C there are two main root classes: NSObject and NSProxy. There are other roots (mainly for private and legacy purposes)

4条回答
  •  眼角桃花
    2020-12-10 05:04

    Objective-C and Cocoa are separate things, and in principle it’s possible to define entirely new application frameworks that don’t use Foundation. The financial analysis people bbum mentioned are a practical example, and I believe they’re still around.

    Another use is to make a proxy that’s more minimal than NSProxy, as Mike Ash does here.

    Oh, and the private NSInvocationBuilder is a root class, presumably for the same reasons as Mike’s proxy. Capturing invocations for later use is something one might want to recreate.

提交回复
热议问题