【问题标题】:[Error]: bad characters in classname - PFQueryTableViewController[错误]:类名中的错误字符 - PFQueryTableViewController
【发布时间】:2015-08-23 15:23:57
【问题描述】:

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

[错误]:类名中的错误字符:(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;
}

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

【问题讨论】:

    标签: parse-platform pfquery pfquerytableviewcontrolle


    【解决方案1】:

    使用接口生成器创建解析提供的 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;
    }
    

    【讨论】:

    • 嗨 Danh,修复了它,现在可以正常工作了。非常感谢:-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多