Here is some interesting question .I am developing an app with tableview. Initially tableview is having 4 rows and all the 4 rows having same images in image views. When i click first row i manually added some sub rows under first row and reloaded the table view. When i second click on same row that i previously clicked i removed the objects that i added manually and reloading tableview. I want to change image for 1 st. row when 1 st. row is clicked and second click on 1 st. row then showing previous image same for all the four rows ..please tell me how to do this.
a=b=c=FALSE
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
///////11111
if(a==FALSE && indexPath.row==0)
{
[array insertObject:@"a" atIndex:1];
[array insertObject:@"b" atIndex:2];
[array insertObject:@"c" atIndex:3];
a=TRUE;
}
else if(indexPath.row==0 && a==TRUE)
{
[array removeObject:@"a"];
[array removeObject:@"b"];
[array removeObject:@"c"];
a=FALSE;
}
else if(a==FALSE && b==FALSE && indexPath.row==1)
{
[array insertObject:@"d" atIndex:2];
[array insertObject:@"e" atIndex:3];
[array insertObject:@"f" atIndex:4];
b=TRUE;
}
else if(a==TRUE && b==FALSE && indexPath.row==4)
{
[array insertObject:@"d" atIndex:5];
[array insertObject:@"e" atIndex:6];
[array insertObject:@"f" atIndex:7];
b=TRUE;
}
else if(a==FALSE && b==TRUE && indexPath.row==1)
{
[array removeObject:@"d"];
[array removeObject:@"e"];
[array removeObject:@"f"];
b=FALSE;
}
else if(a==TRUE && b==TRUE && indexPath.row==4)
{
[array removeObject:@"d"];
[array removeObject:@"e"];
[array removeObject:@"f"];
b=FALSE;
}
/////////3333333333
else if(a==FALSE && b==FALSE && c==FALSE && indexPath.row==2)
{
[array insertObject:@"m" atIndex:3];
[array insertObject:@"n" atIndex:4];
[array insertObject:@"p" atIndex:5];
c=TRUE;
}
else if(a==FALSE && b==TRUE && c==FALSE && indexPath.row==5)
{
[array insertObject:@"m" atIndex:6];
[array insertObject:@"n" atIndex:7];
[array insertObject:@"p" atIndex:8];
c=TRUE;
}
else if(a==TRUE && b==FALSE && c==FALSE && indexPath.row==5)
{
[array insertObject:@"m" atIndex:6];
[array insertObject:@"n" atIndex:7];
[array insertObject:@"p" atIndex:8];
c=TRUE;
}
else if(a==TRUE && b==TRUE && c==FALSE && indexPath.row==8)
{
[array insertObject:@"m" atIndex:9];
[array insertObject:@"n" atIndex:10];
[array insertObject:@"p" atIndex:11];
c=TRUE;
}
else if(a==TRUE && b==TRUE && c==TRUE && indexPath.row==8)
{
[array removeObject:@"m"];
[array removeObject:@"n"];
[array removeObject:@"p"];
c=FALSE;
}
else if(a==TRUE && b==FALSE && c==TRUE && indexPath.row==5)
{
[array removeObject:@"m"];
[array removeObject:@"n"];
[array removeObject:@"p"];
c=FALSE;
}
else if(a==FALSE && b==TRUE && c==TRUE && indexPath.row==5)
{
[array removeObject:@"m"];
[array removeObject:@"n"];
[array removeObject:@"p"];
c=FALSE;
}
else if(a==FALSE && b==FALSE && c==TRUE && indexPath.row==2)
{
[array removeObject:@"m"];
[array removeObject:@"n"];
[array removeObject:@"p"];
c=FALSE;
}
//////4444444444
if(indexPath.row==[array count]-1)
{
---
}
[tableview reloadData];
}