UITableViewCell get nil

Posted by MTA on Stack Overflow See other posts from Stack Overflow or by MTA
Published on 2012-03-25T10:59:49Z Indexed on 2012/03/25 11:30 UTC
Read the original article Hit count: 124

Filed under:
|

I create a UITableView with custom UITableViewCell,this is how i create the cell in cellForRowAtIndexPath:

static NSString *CellIdentifier = @"SongsCell";
    SongsCell *cell = (SongsCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){
        UIViewController *vc = [[[UIViewController alloc] initWithNibName:@"SongsCell" bundle:nil] autorelease];
        cell = (SongsCell *) vc.view;
    }

now i want to get all cells in the table info (parameter from cell) when a button pressed:

for (int i = 0; i < [songTable numberOfRowsInSection:0]; i++)
{

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
    UITableViewCell *cell = [songTable cellForRowAtIndexPath:indexPath];
}

Now i have a problem that this loop give me for cell a nil for all the cell that currently not seen in the table.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c