1

我正在尝试将两个对象或“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;
}
4

2 回答 2

0

只需将更多@propertys 添加到您的视图控制器。确保添加必要的(className2、textKey2 等)并修改表视图的数据源方法以显示数据。

话虽如此,视图控制器以initWithCoder. 这通常是故事板为视图调用的方法。

于 2013-08-04T07:52:35.330 回答
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];
}

}];

}

于 2013-08-04T19:13:38.793 回答