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

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
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:

proto.jpg


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!
 

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
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.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
stadidas said:
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.
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.