ios – setObjectForKey:exception:object不能为nil

ios – setObjectForKey:exception:object不能为nil,第1张

概述我正在使用Parse和 Xcode构建应用程序.使用Parse PFTableView时,我收到错误: Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** setObjectForKey: object cannot be nil (key: classname)’ 我知道我没有在 我正在使用Parse和 Xcode构建应用程序.使用Parse PFtableVIEw时,我收到错误:

Terminating app due to uncaught exception
‘NSinvalidargumentexception’,reason: ‘*** setobjectForKey: object
cannot be nil (key: classname)’

我知道我没有在我的代码中设置密钥,但我不知道在哪里以及如何解决它.

#import "tableVIEwController.h"#import <Parse/Parse.h>@interface tableVIEwController ()@end@implementation tableVIEwController- (ID)initWithStyle:(UItableVIEwStyle)style{    self = [super initWithStyle:style];    if (self) {        // This table displays items in the Todo class        self.parseClassname = @"Todo";        self.pullToRefreshEnabled = YES;        self.paginationEnabled = YES;        self.objectsPerPage = 25;    }    return self;}- (voID)vIEwDIDLoad{    [super vIEwDIDLoad];    // Uncomment the following line to preserve selection between presentations.    // self.cleaRSSelectionOnVIEwWillAppear = NO;    // Uncomment the following line to display an Edit button in the navigation bar for this vIEw controller.    // self.navigationItem.rightbarbuttonItem = self.editbuttonItem;    self.parentVIEwController.vIEw.backgroundcolor = [UIcolor colorWithPatternImage:[UIImage imagenamed:@"red_bokeh.png"]];    self.tableVIEw.backgroundcolor = [UIcolor clearcolor];}- (voID)vIEwDIDUnload{    [super vIEwDIDUnload];    // Release any retained subvIEws of the main vIEw.    // e.g. self.myOutlet = nil;}- (voID)vIEwWillAppear:(BOol)animated{    [super vIEwWillAppear:animated];}- (voID)vIEwDIDAppear:(BOol)animated{    [super vIEwDIDAppear:animated];}- (voID)vIEwWilldisappear:(BOol)animated{    [super vIEwWilldisappear:animated];}- (voID)vIEwDIDdisappear:(BOol)animated{    [super vIEwDIDdisappear:animated];}- (voID)dIDReceiveMemoryWarning{    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}#pragma mark - table vIEw data source#pragma mark - Parse- (voID)objectsDIDLoad:(NSError *)error {    [super objectsDIDLoad:error];    // This method is called every time objects are loaded from Parse via the PFquery}- (voID)objectsWillLoad {    [super objectsWillLoad];    // This method is called before a PFquery is fired to get more objects}- (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 = @"Cell";    UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr];    if (cell == nil) {        cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleSubTitle reuseIDentifIEr:CellIDentifIEr];    }    // Configure the cell    cell.textLabel.text = object[@"text"];    cell.detailTextLabel.text = [Nsstring stringWithFormat:@"Priority: %@",object[@"priority"]];    return cell;}- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath{    [super tableVIEw:tableVIEw dIDSelectRowAtIndexPath:indexPath];}@end

这是tableVIEwController.h:

#import <UIKit/UIKit.h>@interface tableVIEwController : PFquerytableVIEwController@end
解决方法 我按照这个 Parse.com/help解决了这个问题

我只是将方法从initWithStyle更改为initWithCoder.

- (ID)initWithCoder:(NSCoder *)aDecoder    {    self = [super initWithCoder:aDecoder];    if (self) {        // The classname to query on        self.parseClassname = kPAPPhotoClassKey;        // Whether the built-in pull-to-refresh is enabled        self.pullToRefreshEnabled = YES;        // Whether the built-in pagination is enabled        self.paginationEnabled = YES;        // The number of objects to show per page        self.objectsPerPage = 10;    }    return self;}
总结

以上是内存溢出为你收集整理的ios – setObjectForKey:exception:object不能为nil全部内容,希望文章能够帮你解决ios – setObjectForKey:exception:object不能为nil所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1040023.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存