Danny
Danny

Reputation: 454

Add cell to UITableView

Can't handle simple problem - adding cells to UITableView.

I have single-view application, with added from Objects - Table View and simple NSArray (deseriliazed json from internet-grabbed data).

- (void) didLoadMusicList:(APIDownload *)request
{
    NSLog(@"Music list loaded");
    CJSONDeserializer *deserializer = [CJSONDeserializer new];

    NSDictionary *dict = [deserializer deserializeAsDictionary:request.downloadData error:nil];

    NSArray *response = [dict objectForKey:@"response"];
    NSArray *audios = [response subarrayWithRange:NSMakeRange(1, response.count-1)];      

    for(int i = 0; i < audios.count; i++)
    {
        NSDictionary *audio = [audios objectAtIndex:i];

        // add a cell?
    }
}

So, how do I add cell for each element?

Upvotes: 0

Views: 179

Answers (1)

J2theC
J2theC

Reputation: 4452

You need to implement the UITableViewDatasource on your view controller. You can use the same array to provide the data to the cells, and return them using the cellForRowAtIndexPath datasource method. You also need to provide with the count of cells on your tableView.

Check this documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html

Upvotes: 2

Related Questions