// 1.
TestViewController <TestViewControllerProtocol> *testVC = [TestViewController new];
// 2.
TestViewController *testVC = [TestViewController new];
TestViewController.h
@interface TestViewController : UIViewController <TestViewControllerProtocol>
答案 0 :(得分:1)
TestViewController
类型,而只有第一个实现协议TestViewControllerProtocol
。一种可能的情况是,您有一个具有多个子类的超类TestViewController
,其中只有几个实际实现了该协议。如果您有一些代码使用其中两个实现协议的子类,则可以使用第二个选项轻松存储对它们的引用。