且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以让子类看到私有方法和属性?

更新时间:2023-11-10 18:41:46

您可以遵循自己的建议(在单独的标题中声明私有方法),但如果您愿意,可以使用扩展名,而不是类别.

You can follow your own suggestion (declaring the private methods in a separate header), but you can use an extension if you'd prefer, rather than a category.

Apple 通过 UIGestureRecognizer 做到了这一点.看看 UIGestureRecognizerSubclass.h.

Apple does exactly this with UIGestureRecognizer. Take a look in UIGestureRecognizerSubclass.h.