Fixed NSRangeException in TKCalendarMonthView #212

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

When traversing backwards by month, the element at index count +1 was accessed in the marks array, yielding an NSRangeException. I added a check to ensure that the index variable is not beyond the bounds of the marks array, and I also removed the redundant calls to [marks count] within the for-loops of -drawRect: of TKCalendarMonthView.m.

teameh commented on df0cf0b Jan 24, 2013

Good pull request.

How about:

BOOL markForIndex;

for(){...
    markForIndex = (markCount > index) ? [[marks objectAtIndex:index] boolValue] : NO;
    [self drawTileInRect:r day:i mark:markForIndex font:font font2:font2];
....}

Instead of:

for(){...
    if (markCount > 0 && index < markCount)
        [self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] boolValue] font:font font2:font2];
    else
        [self drawTileInRect:r day:i mark:NO font:font font2:font2];
}

?

Cheers!

Owner

devinross commented Mar 20, 2013

@tiemevanveen Yea, that change made the method a lot cleaner. Thanks!

@devinross devinross closed this Mar 20, 2013

teameh commented Mar 20, 2013

You're welcome! Thanks for all the updates :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment