1

I have a an XML response which returns the below data as response

Start Day of the Week-Wednesday
End Day of the Week-Sunday
Start time -16:00
End time -19:00

Now I know how to parse these values ,but I am getting confused on how can I set these values to MaxDate and MinDate of the Date Picker,because the returned response is not same always and may change later,I mean later start day of the week ,end day of the week may change,so how shall I implement it so that it will be efficient..please help me friends..I tried some code which is below,but I am not sure whether i am on the right path,so please show me direction and help me out

NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]
                         initWithCalendarIdentifier:NSGregorianCalendar];

[Gregorian setfirstDayofWeek:2];
NSDateComponents  * comps =[[NSDateComponents alloc]init];
[comps setday:7];
icodebuster
  • 8,890
  • 7
  • 62
  • 65
Ranjit
  • 4,576
  • 11
  • 62
  • 121
  • ok nekto please help me out.. – Ranjit Sep 27 '11 at 05:18
  • How do u parse daa from xml? In what format do u have it? – Nekto Sep 27 '11 at 08:01
  • i have it in string format..i have taken all the data into the array – Ranjit Sep 27 '11 at 08:06
  • Hey Nikto string is same as above in my question..Hey nekto I habe one more doubt,I want to set the time range such that the user can select only those timings,suppose from 16:00 to 19:00,so the user cant select any other timings,how can i achieve that – Ranjit Sep 27 '11 at 08:23
  • I think, you should make 2 pickers. In one picker you can set only 2 dates. Moreover, may be it will be easier if you will make your custom picker? – Nekto Sep 27 '11 at 09:19
  • Hey Nekto I have two diffrent pickers only..one for Date and One for Time – Ranjit Sep 27 '11 at 11:13

1 Answers1

0

So I suggest you to create two UIDatePicker's or one custom UIDatePicker.

If you will select first approach, you can set ranges of time in UIDatePicker in following way:

Using IB:

  1. Select your Date picker.
  2. Open Utilities -> Attribute inspector
  3. In block Constraints :
  4. Select Minimum Date and set its value 01/01/1970 16:00:00
  5. Select Maximum Date and set its value 01/01/1970 19:00:00
  6. Set value Date to 01/01/1970 16:00:00
Nekto
  • 17,837
  • 1
  • 55
  • 65