Lefora Free Forum
login join
Loading
1089 views

NSDatePicker

Page 1
1–7
rookie - member
7 posts

Hi there,
I have a problem of extracting time from the datepicker box. I setup time show in the datepicker box as 1982-10-12 16:00:00 +0000, when I use substringWithRange:NSMakeRange(10,10) to extract the string of time, I got 16:00:00, when I try to convert the string to integer, I got 16, but I can not get the minute and second value. Does anyone have an idea?

?
288 posts

Well you could use a scanner to parse the string and decode it.  That's rather ugly.  Apple provide very good functions for converting strings to dates.  However I wouldn't expect to even use them.  I feel confident (although I've never the date picker) that the control will give you a date or time object or something.  I see to recall that the date picker is rather basic - it's just up/down arrows really and doesn't provide a popup calendar or anything fancy.  I'm sure with a little googleing you'll find something really useful.  If you're still stuck at the weekend, I'll take a closer look at this for you.

__________________
rookie - member
7 posts

Thanks for the advise, I used scanf to retrieve data from the datepicker, it works, not smart, but works :)

rookie - member
7 posts

Another question, how could I set the default date in the NSDatePicker box as today? Couldn't find a solution on internet, maybe can someone give me a good reference link? Thanks

novice - member
25 posts

jz45 try this :


// Create todays date

NSDate *todayDate = [NSDate date];


// use the todayDate as the newStartDate

[self setDateValue:todayDate]



this will set the date pickers value to today every time it program starts

subclass the a NSDatePicker and add this code to the -(void)awakeFromNib{}


^^ it works for me ^^

rookie - member
7 posts

It doesn't work :( it says setDateValue may not work for GuiController, which is my nib name

rookie - member
7 posts

It's working now, thanks a lot!

Page 1
1–7

Locked Topic


You must be a member to post in this forum

Join Now!