Я новичок в Parse с iOS. Я создаю UITableView, который должен быть заполнен объектами Parse. Это методы:UITableView с элементами Parse
- (void)viewDidLoad {
[super viewDidLoad];
[self performSelector:@selector(retrieveFromParse)];
// Do any additional setup after loading the view from its nib.
}
- (void) retrieveFromParse {
PFQuery *retrieveColors = [PFQuery queryWithClassName:@"cadenas"];
[retrieveColors findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
colorsArray = [[NSArray alloc] initWithArray:objects];
NSLog(@"descargado=%@",colorsArray);
}
[self.tableView reloadData];
}];
}
Предыдущий NSLog показывает два существующих объекта Parse.
А теперь методы просмотра таблицы:
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// Return the number of rows in the section.
// Usually the number of items in your array (the one that holds your list)
return [colorsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Where we configure the cell in each row
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
PFObject *tempObject = [colorsArray objectAtIndex:indexPath.row];
NSLog(@"CADNA =%@:",[colorsArray objectAtIndex:indexPath.row]);
cell.textLabel.text = [tempObject objectForKey:@"chain_name"];;
return cell;
}
Последний NSLog не называется, и для этого, то UITableView пуст.
Что я делаю неправильно?
спасибо.
вы установить делегат и источник данных о Tableview? – YuviGr
@YuviGr, да, я сделал. Я тестировал его с помощью NSArray, и отображаются элементы массива. Спасибо. – mvasco
где объявляется colorsArray? – YuviGr