views:

31

answers:

2

I got Error while using UITableView as 'setText:' is deprecated in line cell.text=cellvalue Please anyone can how to fix this?

- (UITableViewCell *)tableView:(UITableView *)atable cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [atable dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];

    cell.text = cellValue; //Error 'setText:' is deprecated 

    return cell;
}
+2  A: 

cell.textLabel.text = @"Value"

NR4TR
thanks... it worked..
Chinthan Kyasanur
A: 

Because Apple added the Subtitle style to the table view cells, you need to use:

[cell.textLabel setText:@"String"];

instead.

Evan Mulawski
Thanks a lot... it worked...
Chinthan Kyasanur
If you want to use the subtitle, change initWithFrame:CGRectZero to initWithStyle:UITableViewCellStyleSubtitle. Set the subtitle text using [cell.detailTextLabel setText:@"String"];
Evan Mulawski
really effective...
Chinthan Kyasanur
How to restrict the tables? i have only 5 cell data. I need to restrict the count of rows to 5...
Chinthan Kyasanur
If you have one section, use the numberOfRowsInSection protocol method as described here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html%23//apple_ref/occ/intf/UITableViewDataSource
Evan Mulawski