Note that there are some explanatory texts on larger screens.

plurals
  1. POusing of two different type of custom cell in same table view?
    primarykey
    data
    text
    <p>thanks in advance. in my app, i have a tableview, in which i have to use two different style of custom cell, i made two custom cell, and in tableView cellForRowAtIndexPath method i used two identifier for cell, even i tried for two section. but its not working. it is giving me "EXE BAD Excess" or some time other kind of error. below is my code.</p> <p>Error : thread1_EXE_BAD_Access(code = 2 ,address 0 x 0)</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { //CatIdentifier static NSString *CellIdentiFier = @"CatIdentifier"; static NSString *Cell1IdentiFier = @"CatIdentifier1"; if (indexPath.section == 0) { CommitteCell *cell = ( CommitteCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentiFier]; if(cell == nil) { cell = ( CommitteCell *)[[[NSBundle mainBundle] loadNibNamed:@"CommitteeCell" owner:self options:nil] objectAtIndex:0]; } if (indicator == 1) { cell.lblName.text = str; } else { cell.lblName.text = [arrayName objectAtIndex:indexPath.row]; cell.lblPost.text = [arrayPost objectAtIndex:indexPath.row]; cell.picimg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[arrayimage objectAtIndex:indexPath.row]]]]; } cell.backgroundView = [[UIImageView alloc]init]; UIImage *img = [UIImage imageNamed:@"link-bg 2.png"]; ((UIImageView *)cell.backgroundView).image = img; return cell; } else { Committee2Cell *cell1 = (Committee2Cell *)[tableView dequeueReusableCellWithIdentifier:Cell1IdentiFier]; if(cell1 == nil) { cell1 = (Committee2Cell *)[[[NSBundle mainBundle] loadNibNamed:@"Committee2Cell" owner:self options:nil] objectAtIndex:0]; } cell1.lblPost1.text = strPost; cell1.txtName.text = strName; cell1.backgroundView = [[UIImageView alloc]init]; UIImage *img = [UIImage imageNamed:@"link-bg 2.png"]; ((UIImageView *)cell1.backgroundView).image = img; return cell1; } } </code></pre> <p>section in tableview and rows in section method are as below.</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { switch (section) { case 0: return [arrayName count]-1; break; case 1: return 1; break; default: break; } return 0; } </code></pre> <p>please if anyone can fine that where is my mistake . thanks again.</p> <p>data of array and label is as below.</p> <p>-(void)NewsParser:(NSMutableDictionary *)dic { NSLog(@"dic = %@",dic);</p> <pre><code> arrayName = [[NSMutableArray alloc]init]; arrayPost = [[NSMutableArray alloc]init]; arrayimage= [[NSMutableArray alloc]init]; strPost = [[NSString alloc]init]; strName = [[NSString alloc]init]; strPost = [[dic valueForKey:@"post"]objectAtIndex:8]; strName = [[dic valueForKey:@"name"]objectAtIndex:8]; NSLog(@"Name = %@",strName); NSLog(@"Post = %@",strPost); for(int i=0;i&lt;[dic count]-1;i++) { [arrayName addObject:[[dic valueForKey:@"name"]objectAtIndex:i]]; [arrayPost addObject:[[dic valueForKey:@"post"]objectAtIndex:i]]; [arrayimage addObject:[[dic valueForKey:@"pic"]objectAtIndex:i]]; } NSLog(@"array = %@",arrayName); NSLog(@"array = %@",arrayPost); NSLog(@"array = %@",arrayimage); [table1 reloadData]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload