Note that there are some explanatory texts on larger screens.

plurals
  1. POsetObjectForKey: exception: object cannot be nil
    primarykey
    data
    text
    <p>I am building an app using Parse and Xcode. When using the Parse <code>PFTableView</code> I am getting the error: </p> <blockquote> <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: classname)'</p> </blockquote> <p>I understand that I am not setting the key somewhere in my code, but I do not know where and how to fix it.</p> <pre><code>#import "TableViewController.h" #import &lt;Parse/Parse.h&gt; @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 </code></pre> <p>Here is the TableViewController.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface TableViewController : PFQueryTableViewController @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload