View Full Version : iphone SDK problems passing variables

Jan 18, 2009, 02:45 AM
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.

- (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];


Jan 18, 2009, 03:33 AM
NSDate *now = [NSDate date]; sry Fixed it.