S
S
Sunset_over2015-05-05 18:10:24
iOS
Sunset_over, 2015-05-05 18:10:24

How to split row and populate tableview?

Good evening, I receive a json string [email protected]"1,2,3,4" I need to divide each number and fill in the table. array = [str componentsSeparatedByString: @","];Found this way but there are some problems with filling the table

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
one pavel, 2015-05-05
@onepavel

The componentsSeparatedByString method is very nice for separation. You can also
[NSJSONSerialization JSONObjectWithData:]

P
Petrushka, 2015-05-06
@petruska

you just need to fill the cells of the table with array elements?
Well, it's not difficult, I advise you to read about it (since this is the basis of the basics)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    //Поиск ячейки
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    //Если ячейка не найдена
    if (cell == nil) {
        //Создание ячейки
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                       reuseIdentifier:CellIdentifier];
    }
    
    // !!!
    cell.textLabel.text = [students objectAtIndex:indexPath.row];
    
    return cell;
}

students - our
table array - www.imaladec.com/story/uitableview

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question