mardi 23 juin 2015

How to use a UITableView section index as an NSInteger?

I want to set the kJTCalendarDaySelected of my JTCalendar to be equal to the index.section that is visible. If the index is 0, I want kJTCalendarDaySelected set to 1 (1st of the month), if the index is 1, I want it set to 2 (2nd of the month), and so on.

When I try to do this like so:

-(BOOL)whatSectionsAreVisible {
    NSArray *visibleRowIndexes = [self.agendaTable indexPathsForVisibleRows];
    for (NSIndexPath *index in visibleRowIndexes) {

        self.daySection = index.section;

        // Update views
        [[NSNotificationCenter defaultCenter] postNotificationName:@"kJTCalendarDaySelected" object:self.daySection];

        // Store currentDateSelected
        [self.calendar setCurrentDateSelected:self.daySection];

        NSLog(@"The visible section has an index of: %ld", (long)index.section);

        if (index.section == 0) {
            NSLog(@"index.row is indeed 0");
            return YES;
        }
    }
    return NO;
}

I get the following error:

implicit conversion of non-Objective-c pointer type 'NSInteger' (aka 'long') to 'id' is disallowed with ARC enter image description here

How can I convert index.section's id to an NSInteger that can be used for this purpose?

See more ..

Aucun commentaire:

Enregistrer un commentaire