我对Xcode 7中的泛型类型支持做了一个简单的测试,如下所示:
@interface MTBaseListViewController <T> : UIViewController
- (void )requestWithBlock1:(void (^)(T data ))block;
- (void )requestWithBlock2:(void (^)(MTListPagingModel<T> *data ))block;
@end;
接口编译没有问题。
然后在使用它的班级
@interface MTTestViewController : MTBaseListViewController <MTTestModel *>
@end
@implementation MTTestViewController
- (void )requestWithBlock1:(void (^)(MTTestModel *data ))block {
}
- (void )requestWithBlock2:(void (^)(MTListPagingModel<MTTestModel *> *data ))block {
}
@end
两种方法都会抱怨“实施中的参数类型冲突......”
我在enumerateObjectsUsingBlock
支持类型中看到NSArray<ObjectType> (NSExtendedArray )
方法在块内推断。所以我认为应该是我的问题没有以正确的方式声明类型?