1
我正在嘗試構建一個應用程序,用戶可以在該應用程序中像Instagram一樣喜歡和評論帖子。所有帖子/贊/評論都保存在parse.com上!我已經能夠放在一起的代碼,它應該工作,因爲它確實在示例應用程序,但是當我移動過的文件,此代碼使它崩潰:NSInvalidArgumentException:應用程序在開啓時崩潰
[query whereKey:@"user" containedIn:self.usersToDisplay];
墜毀消息是:
終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:「* setObjectForKey:對象不能是零(關鍵:$的)」 **
的代碼的其餘部分是這樣的:
- (void)viewDidLoad
{
// self.usersToDisplay = @[[PFUser currentUser]];
self.parseClassName = @"Photo";
[super viewDidLoad];
self.tableView.layer.cornerRadius = 10;
self.tableView.layer.masksToBounds = YES;
}
- (void)setUsersToDisplay:(NSArray *)usersToDisplay {
_usersToDisplay = usersToDisplay;
if (self.isViewLoaded)
{
[self loadObjects];
}
}
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
// If Pull To Refresh is enabled, query against the network by default.
if (self.pullToRefreshEnabled) {
query.cachePolicy = kPFCachePolicyNetworkOnly;
}
[query whereKey:@"user" containedIn:self.usersToDisplay];
[query addDescendingOrder:@"createdAt"];
return query;
}
-(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
PhotoViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ImageCellReuseID"];
if(!cell)
{
cell = [[PhotoViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"ImageCellReuseID"];
}
cell.imageView.file = object[@"image"];
[cell.imageView loadInBackground];
NSDateFormatter* formatter = [NSDateFormatter new];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateStyle:NSDateFormatterShortStyle];
NSString* uploaded = [formatter stringFromDate:object.createdAt];
cell.textLabel.text = [NSString stringWithFormat:@"Taken By %@ ", object[@"username"]];
cell.detailTextLabel.text = uploaded;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"ShowDetail" sender:indexPath];
}
任何想法爲什麼它崩潰?