我正在使用解析,我试图在我的tableview的副标题中显示PFUser名称。当我尝试在下面的代码中显示时,它会崩溃我的程序。
保存PFObject:
PFUser *user = [PFUser currentUser];
PFObject *quoteNew = [PFObject objectWithClassName:@"New"];
[quoteNew setObject:user forKey:@"user"];
[quoteNew setObject:[[self quoteText] text] forKey:@"Text"];
查询用户:
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Customize the table
// The className to query on
self.parseClassName = @"New";
// self.className2 = @"Story";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"title";
self.User = @"user";
// self.textKey2 = @"title";
// 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 = 100;
}
return self;
}
尝试显示用户:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
// If you want a custom cell, create a new subclass of PFTableViewCell, set the cell identifier in IB, then change this string to match
// You can access any IBOutlets declared in the .h file from here and set the values accordingly
// "Cell" is the default cell identifier in a new Master-Detail Project
static NSString *CellIdentifier = @"Cell";
PFTableViewCell *cell = (PFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell
cell.textLabel.text = [object objectForKey:self.textKey];
cell.detailTextLabel.text = [object objectForKey:self.User];
//cell.imageView.file = [object objectForKey:self.imageKey];
return cell;
}