Objective C-Block Generation

I am trying to implement a data source that can be used to configure several different cell classes to represent a table, but I am having problems with a common type in the block that I pass to the constructor.

Here is the implementation of the data source header file:

@interface ABParseDatasource<__covariant ObjectType: UITableViewCell *> : NSObject <UITableViewDataSource>

- (instancetype)initWithCellIdentifier:(NSString *)identifier parseQuery:(PFQuery *)query tableView:(UITableView *)tableView customizeBlock:(void (^)(ObjectType))customBlock;

@end

And this is where I try to initialize the block in the constructor:

self.parseDatasource = [[ABParseDatasource alloc] initWithCellIdentifier:identifier parseQuery:[ABOrder query] tableView:self.tableView customizeBlock:^(ABOrderItemTableViewCell *cell) {

}];

Property Declaration:

@property (nonatomic) ABParseDatasource<ABOrderItemTableViewCell *> *parseDatasource;

But I get a compiler error when instantiating the data source:

enter image description here

Any ideas? (And yes ABOrderItemTableViewCellinherit from UITableViewCell)

0
source share
1 answer

When creating a class, you must specify a generic type:

[[ABParseDatasource<ABOrderItemTableViewCell *> alloc] initWithCellIdentifier...
+2
source

Source: https://habr.com/ru/post/1627288/


All Articles