How to Add NSTimeInterval to NSMutableArray?

Discussion in 'iPhone/iPad Programming' started by Stunner, Nov 11, 2009.

  1. macrumors newbie

    Joined:
    Sep 14, 2009
    #1
    I am having problems adding NSTimeInterval to an NSMutableArray. Here is my code:
    Code:
                    NSTimeInterval timeDifference;
    		timeDifference = [[self.arrayOfTimes objectAtIndex:arrayOfTimesCtr-1] 
    						  timeIntervalSinceDate:[self.arrayOfTimes objectAtIndex:arrayOfTimesCtr-2]];
    		[self.arrayOfTimeDifferences addObject:timeDifference]; //problem here
    
    
    And the error I get from the problematic line is "error: incompatible type for argument 1 of 'addObject:'". So what I get from this is that it wants an object rather than a value, but I have looked through the array documentation and there are only addObject methods. Therefore I am wondering how I can append a regular value, like an int, or an NSTimeInterval for that matter, to an array. Thanks!
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Convert it to an object using NSNumber.
     
  3. thread starter macrumors newbie

    Joined:
    Sep 14, 2009
    #3
    Awesome, thanks man. Figured it out.
     

Share This Page