[错误]:classname中的错误字符 - PFQueryTableViewController

时间:2015-08-23 15:23:58

标签: parse-platform pfquery pfquerytableviewcontrolle

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

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

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

- (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;
}

非常感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分: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;
}