【发布时间】:2015-08-22 18:05:31
【问题描述】:
您好,刚开始使用 Parse,我正在尝试使用 Parse PFQuery 检索的数组中的数据加载一个简单的表视图控制器。虽然我可以 nslog 加载视图中的“类别”数组,但当代码到达 numberOfRowsInSection 时,该数组似乎已重置为零。 对此的任何帮助将不胜感激。 顺便说一句,我确实尝试过将代码加载到带有文字的数组中,并且表格显示正常没有问题。 代码如下:
@implementation DisplayCategoriesTVC
NSArray *categories;
- (void)viewDidLoad {
[super viewDidLoad];
// CODE TO RETRIEVE CONTENTS OF THE PARSE CATEGORIES CLASS
PFQuery *query = [PFQuery queryWithClassName:@"Categories"];
// [query whereKey:@"Sequence" > @1];
[query findObjectsInBackgroundWithBlock:^(NSArray *categories, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(@"Successfully retrieved %lu categories.", (unsigned long)categories.count);
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [categories count];
}
我的具体问题是,为什么在 numberOfRowsInSection 类别数组显示 nil 值?
我的具体问题是,为什么类别数组现在显示为 nil,我可以做些什么来保留 PFQuery 加载的值并在我的其他方法中使用它们?
【问题讨论】:
标签: ios objective-c uitableview parse-platform pfquery