Used UICollectionView
to generate a seat map. So now which ever cell is selected, getting it's indexPath
but how to use the selected cell indexPath
in showing as row and seat no.
Below is way i tried.
int ind = indexPath.item;
[array addObject:[NSString stringWithFormat:@"%d", ind]];
It gives output as below.
"<NSIndexPath 0x12135500> 2 indexes [0, 1]"
How to acces this thing and get only value 0,1. Please guide for the above.
once look at this one,it'l helps you
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
int ind = indexPath.item;
int section=indexPath.section;
[arr addObject:[NSString stringWithFormat:@"%d",ind]];
NSLog(@"%d,%d",section,ind);
}
Edit:
if([arr containsObject:[NSString stringWithFormat:@"%d",ind]]){
[arr removeObject:[NSString stringWithFormat:@"%d",ind]];
}
or
int n=[array indexOfObject:[NSString stringWithFormat:@"%d",ind]];
if([n<[array count]]){
[array removeObjectAtIndex:n];
}