我在爲留言評論的用戶檢索配置文件圖像時遇到問題。下面是我使用檢索自定義用戶的配置文件圖像
HTKSampleTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"commentReuseID"];
PFObject *comment = [comments objectAtIndex:indexPath.row];
cell.commentLabel.text = [comment objectForKey:@"text"];
NSDateFormatter* formatter = [NSDateFormatter new];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateStyle:NSDateFormatterShortStyle];
NSString* uploaded = [formatter stringFromDate:comment.createdAt];
cell.timeLabel.text = uploaded;
cell.titleLabel.text = [comment objectForKey:@"author"];
[cell.samImageView loadInBackground];
PFUser *currentUses = [comment objectForKey:@"author"];
[currentUses fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
NSString *userphoto = [object objectForKey:@"image"];
NSLog(@"%@", userphoto);
}];
的代碼時,我使用的NSLog,currentUses爲I級保存我的職位,如返回用戶的用戶名「作者」。
這是錯誤我得到:
終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是: ' - [__ NSCFString fetchIfNeededInBackgroundWithBlock:]:無法識別的選擇發送到實例0x15f4d670'
上面的查詢確實有:[query includeKey:@「user」];
在tableview之外嘗試一次,並檢查是否得到相同的錯誤 –
代碼返回的值[comment objectForKey:@「author」]看起來像NSString,因爲您正在設置cell.titleLabel.text = [comment objectForKey: @「作者」];稍後,您將設置PFUser * currentUses = [comment objectForKey:@「author」],它是NSString不是PFUser。 –