Ios 目标C区仿制药
我正在尝试实现一个数据源,该数据源可用于为tableview自定义多个不同的单元格类,但我在传递给构造函数的块中遇到了泛型类型的问题 以下是数据源头文件的实现:Ios 目标C区仿制药,ios,objective-c,generics,objective-c-blocks,Ios,Objective C,Generics,Objective C Blocks,我正在尝试实现一个数据源,该数据源可用于为tableview自定义多个不同的单元格类,但我在传递给构造函数的块中遇到了泛型类型的问题 以下是数据源头文件的实现: @interface ABParseDatasource<__covariant ObjectType: UITableViewCell *> : NSObject <UITableViewDataSource> - (instancetype)initWithCellIdentifier:(NSString
@interface ABParseDatasource<__covariant ObjectType: UITableViewCell *> : NSObject <UITableViewDataSource>
- (instancetype)initWithCellIdentifier:(NSString *)identifier parseQuery:(PFQuery *)query tableView:(UITableView *)tableView customizeBlock:(void (^)(ObjectType))customBlock;
@end
财产声明:
@property (nonatomic) ABParseDatasource<ABOrderItemTableViewCell *> *parseDatasource;
@property(非原子)ABParseDatasource
有什么想法吗?(是的,aborteritemtableviewcell
确实继承自UITableViewCell
)创建类时必须指定泛型类型:
[[ABParseDatasource<ABOrderItemTableViewCell *> alloc] initWithCellIdentifier...
[[ABParseDatasource alloc]initWithCellIdentifier。。。
如何在@implementation
中声明init…
?@Sulthan-(instancetype)initWithCellIdentifier:(NSString*)标识符解析查询:(PFQuery*)查询表视图:(UITableView*)表视图自定义块:(void(^)(UITableViewCell*,PFObject*))自定义块{在Obj-C中的imgur泛型不是用户友好的,它们是为了更好地与Swift进行互操作,而不是为了使Obj-C更好。+1@Sulthan除此之外,动态类型语言具有“内置泛型”(id
typed references)。“类似模板”泛型是一种打破静态类型语言限制的技术。对于动态类型语言来说,没有任何限制需要打破。非常感谢!我一直想知道如何使泛型与初始值设定项一起工作!
[[ABParseDatasource<ABOrderItemTableViewCell *> alloc] initWithCellIdentifier...