我有一个带有UISwitch的数组列表。当开关更改为ON或OFF时,如何使用UISwitch = ON获取数组列表?我将使用该列表在其他ViewController中显示信息。
cell.m
- (void) switchToggled:(id)sender {
UISwitch *theSwitch = (UISwitch *)sender;
if(theSwitch.on)
{
// switch turned on
!_switchSelectCategoryClick ? : _switchSelectCategoryClick();
}
else
{
// switch turned off
!_switchRemoveCategoryClick ? : _switchRemoveCategoryClick();
}
}
ViewController.m
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *gridcell = nil;
if (indexPath.section == 0) {
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellID forIndexPath:indexPath];
cell.strCategoryName = [aryMerchantCategoryList [indexPath.row]valueForKey:@"category_name"];
cell.switchSelectCategoryClick = ^{
[aryMerchantCategoryList [indexPath.row]valueForKey:@"category_id"];
//HOW CAN I STORE WHOLE UISWITCH = ON LIST HERE?
}
};
cell.switchRemoveCategoryClick = ^{
[aryMerchantCategoryList [indexPath.row]valueForKey:@"category_id"];
//HOW CAN I STORE WHOLE UISWITCH = ON LIST HERE?
};
gridcell = cell;
}
return gridcell;
}