Simple Cocoa app - need some help

Discussion in 'Mac Programming' started by stadidas, Oct 22, 2006.

  1. stadidas macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #1
    I'm writing an app in Cocoa and Objective C as an improved version of a program I wrote in Java last year. The basic idea is to help the user manage money whilst at Uni (i.e me). This is what it looks like so far:

    [​IMG]

    The top NSDatePicker is set to the system current time. I would like to be able to set the date on the lower NSDatePicker (probably using the setDateValue method) by clicking on a day on the date picker. At the moment clicking on a day highlights it, but does not change it's value.
    Once this is done I would like to be able to compare the two NSDatePickers and generate an integer value equal to the number of days difference between the two.

    If anyone can help with this I would be very grateful indeed!
     
  2. stadidas thread starter macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #2
    OK, I figured out how to get the currently selected date, you just use dateValue. Earlier in my code I had been re-setting the NSDatePicker to current date and that was causing my confusion.
    Now I just need to figure out how to do the comparison. I'd still be grateful if someone could help me out with that.
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    NSDate objects have the method timeIntervalSinceDate: which you pass a second date to. The returned value is the number of seconds (as an NSTimeInterval value, which is really just a double) between the two dates.
     

Share This Page