jeudi 13 août 2015

UICollectionView saving null

I have an app that allows a user to upload objects and adds various attributes to that object in a collection view. That part is working fine.

I'm adding a filter to the search feature. I'd like to have a similar collection view that a user can select different tags/cells that I'll then be able to use to filter the results. For some reason however my NSArray is not getting saved. Probably something obvious, but I keep trying to resolve without success.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell;

    ItemFilterCell *aCell = (ItemFilterCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"itemFilterCell" forIndexPath:indexPath];
        aCell.label.text = self.itemFilterPresets[indexPath.section][indexPath.row];
    cell = aCell;
 return cell;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray * selectedRows = self.collectionView.indexPathsForSelectedItems;

    for (NSIndexPath * selectedRow in selectedRows) {
        if ((selectedRow.section == indexPath.section) && (selectedRow.row != indexPath.row)) {
            [self.collectionView deselectItemAtIndexPath:selectedRow animated:NO];
        }
    }
    switch (indexPath.section) {
        case 0:
            self.filterSetting.criteria1 = self.itemFilterPresets[indexPath.section][indexPath.row];
            break;
        case 1:
            self.filterSetting.criteria2 = self.itemFilterPresets[indexPath.section][indexPath.row];
            break;
        ....
        default:
            break;
    }
    NSLog(@"criteria1 -----> %@",self.filterSetting.criteria1);
     ....
*********[these all log as null though selected]************

This is correct tho. Just not saving to filterSetting: NSLog(@"criteria1 -----> %@",self.itemFilterPresets[indexPath.section][indexPath.row);

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire