tags:

views:

22

answers:

1

in order to remove the duplicate data in table section view i am doing this now i dont know whether this is good or not so kindly help

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //UILabel *labelb;
    UILabel *labela;
    UILabel *labelt;


    static NSString *FirstRowCellIdentifier = @"A";
    static NSString *FirstRowCellIdentifierb = @"Aa";
    static NSString *OtherRowCellIdentifier = @"B";
    static NSString *OtherRowCellIdentifierb = @"Bc";

    static NSString *SecondRowCellIdentifier = @"C";
    static NSString *SecondRowCellIdentifierb = @"Cb";
    static NSString *SecondRowCellIdentifierc = @"Cc";


    static NSString *CellIdentifier = nil;//@"Cell";

//  NSLog(@"M I BEING CALLED");


    if ([indexPath section] == 0  )
    {
        NSLog(@" 0");
        CellIdentifier = FirstRowCellIdentifier;



    }
    if ([indexPath section] == 1  )
    {
        NSLog(@" 1");
        CellIdentifier = FirstRowCellIdentifierb;



    }

    if ([indexPath section] == 2  )
    {NSLog(@" 2");

        CellIdentifier = OtherRowCellIdentifier;



    }

    if ([indexPath section] == 3  )
    {
        NSLog(@" 3");
        CellIdentifier = OtherRowCellIdentifierb;



    }


if ([indexPath section] == 4 )
{NSLog(@" 4");
        CellIdentifier = SecondRowCellIdentifierb;

    }

if ([indexPath section] == 5 )
{NSLog(@" 5");
CellIdentifier = SecondRowCellIdentifier;

}if ([indexPath section] == 6 )
{NSLog(@" 5");
    CellIdentifier = SecondRowCellIdentifierc;

}





  UITableViewCell *  cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    //number++;
//  NSLog(@" NUMBER IS %d",number);
   // if (cell != nil)
    //if(number==1);
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        //  
        //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1   reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        //appDelegate=(XMLAppDelegate*)[UIApplication sharedApplication].delegate;
        //aBook=[appDelegate.books objectAtIndex:indexPath.row];


    switch(indexPath.section)
        {       


            case 0:
case 1:
}
A: 

Why not just an array of string? Array index will be the section and string, the cell identifier:

static NSArray * CellIdentifiers = [Array arrayWithObjects:@"A",@"Aa",...,nil];
CellIdentifier = [CellIdentifiers objectAtIndex:indexPath.section];
Benoît
yes but is this a good way to assign each cell section new identifier ?? i mean if i use NSlog("2") then it print each time i scroll my table is that can be seen as memory issues??
prajakta
It depends if cells are the same style or not. See TableView programming guide:(http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/CreateConfigureTableView/CreateConfigureTableView.html#//apple_ref/doc/uid/TP40007451-CH6-SW5)If it is just text that change from a cell to an other, use the same cell identifier.
Benoît
it is indeed text but my image also use to shuffle whenever i scroll hardly .. what do you think is the best way to solve this
prajakta