我正在尝试将两个对象或“classNames”显示为PFQueryTableViewController
。到目前为止,我的代码只有一个对象。我似乎无法添加多个对象。
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Customize the table
// The className to query on
self.className = @"Funny";
//self.className = @"Story";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"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;
}
答案 0 :(得分:0)
只需向视图控制器添加更多@property
即可。确保添加必要的(className2,textKey2等)并修改表视图的数据源方法以显示数据。
话虽如此,视图控制器以initWithCoder
启动似乎很奇怪。这通常是故事板为视图调用的方法。
答案 1 :(得分:0)
保存帖子时我使用了两个对象。它工作得很好!
PFObject *quoteNew = [PFObject objectWithClassName:@"New"];
[quoteNew setObject:[[self attribution] text] forKey:@"by"];
[quoteNew setObject:[[self quoteText] text] forKey:@"quoteText"];
[quoteNew setObject:[[self attributionTitle] text] forKey:@"title"];
[quoteNew saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[self done:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Uh oh. Somthing went wrong"
message:[[error userInfo] objectForKey:@"error"]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil] show];
}
}];
PFObject *quote = [PFObject objectWithClassName:@"Funny"];
[quote setObject:[[self attribution] text] forKey:@"by"];
[quote setObject:[[self quoteText] text] forKey:@"quoteText"];
[quote setObject:[[self attributionTitle] text] forKey:@"title"];
[quote saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[self done:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Uh oh. Somthing went wrong"
message:[[error userInfo] objectForKey:@"error"]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil] show];
}
}];
}