我尝试在PFQueryTableViewController中显示两个对象或"classNames“。到目前为止,我的代码中只有一个对象。我似乎不能添加多个对象。
-(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;
}发布于 2013-08-04 15:52:35
只需将更多的@property添加到视图控制器。确保添加必要的方法(className2、textKey2等),并修改表视图的数据源方法以显示数据。
也就是说,视图控制器是用initWithCoder初始化的,这似乎很奇怪。这通常是storyboard为视图调用的方法。
发布于 2013-08-05 03:13:39
我在保存帖子时使用了两个对象。它完美地工作了!
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];
}
}];}
https://stackoverflow.com/questions/18040152
复制相似问题