协议
@protocol Song <NSObject>
@end
Animal对象实现协议Song并定义泛型 ObjectType
#import <Foundation/Foundation.h>
#import "Song.h"
@interface Animal <__covariant ObjectType> : NSObject <Song>
@end
Dog对象继承Animal对象
#import <Foundation/Foundation.h>
#import "Animal.h"
@interface Dog <ObjectType> : Animal <ObjectType>
@end
Golden对象继承Dog对象并定义自己具体类型
#import "Dog.h"
#import "xxxObject.h"
NS_ASSUME_NONNULL_BEGIN
@interface Golden : Dog <xxxObject *>
@end
NS_ASSUME_NONNULL_END
网友评论