ViewControllerClass在这里是什么意思?
据我所知,这不是协议、委托或扩展。任何人都可以解释这是如何工作的?
.h文件:
@interface BaseViewControllerTest <ViewControllerClass> : XCTestCase
@property ViewControllerClass viewController;
- (void)setUpTestWithStroyboardName:(NSString *)viewControllerName;.m文件:
@implementation BaseViewControllerTest
- (void)setUpTestWithStroyboardName:(NSString *)viewControllerName {}如下所示:
#import "BaseViewControllerTest.h"
@interface CTSelectChildAccountViewControllerTests : BaseViewControllerTest <CTSelectChildAccountViewController *>
@end发布于 2016-06-27 22:13:43
从Xcode7开始,Objective-C支持generics
Objective-C已更新,使其与Swift能够更轻松、更高效地协作。新的Objective-C语言特性包括:
CTSelectChildAccountViewController是一个ViewController。将平均ViewControllerClass定义为UIViewController
实例化中的星号也是相关的,因此ViewControllerClass viewController被解释为CTSelectChildAccountViewController* viewController。
除了Swift还有什么好处?
Objective C编译器现在有了更多的类型信息,因此它可以对您调用的方法执行更好的检查。例如,您可以使用包含在其中的类型对Cocoa集合进行注释,例如NSArray<NSString*> *array,并让编译器发现意外插入错误类型的位置。
和它对Swift有什么用处?
Swift内置了对泛型的支持。向您的Objective-C API添加轻量级泛型可以更容易地与Swift交互,因为您的API可以更精确地转换。例如,从Swift翻译您的示例将保持其泛型性质,而不是将泛型类型参数ViewControllerClass替换为其基类型。
https://stackoverflow.com/questions/38056122
复制相似问题