1

您好我一直在尝试测试 Parse PFQueryTableViewController 的功能...但是一直收到以下错误:

[错误]:类名中的错误字符:(null)(代码:103,版本:1.8.0)

我正在使用 Parse 网站上的标准代码来执行此操作并尝试从我的 Pase 类中加载 tableviewcontroller:Categories 即:

- (instancetype)initWithStyle:(UITableViewStyle)style {
    self = [super initWithStyle:style];
    if (self) { // This table displays items in the Todo class
        self.parseClassName = @"Categories";
        self.pullToRefreshEnabled = YES;
        self.paginationEnabled = YES;
        self.objectsPerPage = 25;
    }
    return self;
}

- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];

    // If no objects are loaded in memory, we look to the cache first to fill the table
    // and then subsequently do a query against the network.
//    if (self.objects.count == 0) {
//        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
//    }

    [query orderByDescending:@"createdAt"];

    return query;
}



- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
                        object:(PFObject *)object {
    static NSString *cellIdentifier = @"categoryCell";

    PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                      reuseIdentifier:cellIdentifier];}

    // Configure the cell to show todo item with a priority at the bottom

    cell.textLabel.text = object[@"Category"];
    cell.detailTextLabel.text = object[@"Sequence"];

    return cell;
}

任何帮助都将得到很好的充分接受,谢谢。

4

1 回答 1

2

使用接口生成器创建解析提供的 vc 时存在问题:IB 视图控制器是用 初始化的initWithCoder:,而不是initWithStyle

覆盖任何一种初始化程序的一种方法是分解自定义代码并实现两者,如下所示:

- (void)customInit {
    self.parseClassName = @"Categories";
    self.pullToRefreshEnabled = YES;
    self.paginationEnabled = YES;
    self.objectsPerPage = 25;
}

- (id)initWithStyle:(UITableViewStyle)style {
    self = [super initWithStyle:style];
    if (self) {
        [self customInit];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self customInit];
    }
    return self;
}
于 2015-08-23T17:21:09.100 回答