Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MasterObiWan

macrumors newbie
Original poster
Jan 12, 2009
18
0
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? :mad:
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];
	
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.