YYModel icon indicating copy to clipboard operation
YYModel copied to clipboard

是否支持泛型?

Open wilddylan opened this issue 8 years ago • 4 comments

在使用过程中,我有一部分数据需要使用泛型进行聚合。

@interface HDModel<T> : NSObject

// 数据列表
@property ( nonatomic, strong ) NSArray<T> *allList;

/**
 近期最高数据
 */
@property ( nonatomic ) T highestDate;

/**
 近期最低数据
 */
@property ( nonatomic ) T lowestDate;

/**
 近期最新数据
 */
@property ( nonatomic ) T newestDate;

@end

大致是上述的类型,不知是否支持次类型。 因为在 mapper 处我无法反回 allList的数据类型。 T 可能是NSInteger 也可能是 某个类,或者 NSString等等类型

wilddylan avatar Mar 06 '17 15:03 wilddylan

同问

IDOKN avatar Jun 19 '17 05:06 IDOKN

image

IDOKN avatar Jun 19 '17 05:06 IDOKN

Do you write and test with objective-C ?

wilddylan avatar Jun 19 '17 10:06 wilddylan

不支持。OC 的所谓范型只是用于给编译器提供信息的,运行时是没有具体信息的。

ibireme avatar Aug 06 '17 16:08 ibireme