iphone SDK problems passing variables

Discussion in 'iPhone/iPad Programming' started by MasterObiWan, Jan 18, 2009.

  1. macrumors newbie

    Joined:
    Jan 12, 2009
    #1
    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];
    	
    }
    
    
     
  2. thread starter macrumors newbie

    Joined:
    Jan 12, 2009
    #2
    NSDate *now = [NSDate date]; sry Fixed it.
     

Share This Page