I am trying to pass an integer into a method, I get no errors however when I test in simulator the app crashes. Is there some sort of extra rule that I have to follow in order to pass variables in Objective C?
Thanks if someone can help me. I've added comments to make the code easier to understand.
Thanks if someone can help me. I've added comments to make the code easier to understand.
Code:
- (void)whatMonthIsIt:(int)monthOfYear{
NSString* monthArray[5];
monthArray[1] = @"jan.png";
img_dates = [UIImage imageNamed:monthArray[monthOfYear]]; //sets img_dates to @"jan.png";
}
- (void)onTimer:(NSTimer*)timer{ //Thread
NSDate *now;
int monthOfYear = [[now dateWithCalendarFormat:nil timeZone:nil] monthOfYear]; //gets the current month and stores into integer monthOfYear
[self whatMonthIsIt:monthOfYear]; //passes monthOfYear to method whatMonthIsIt
[self setNeedsDisplay];
}