0

I am working on project where I want to integrate NSCalendar functionality in my app. Hence I googled and I found this solution. It give me all months in the year and also I can select particular date. that's fine. But I wanted to disable all saturdays and sundays of every month somehow I tried to do it but when I tap previous month or next month it changes the selection. I have gone through almost all stackoverflow questions But I didn't find proper way to do it. I request you to all Is there any flexible solution on this where I can disable weekends and any particular date. The flow should be like this:

  1. Run the application current month is display and all sat & sun disabled.
  2. When tap on next month or previous month, the respective sat & sun should be disable as per that month.
  3. Functionality for any particular date that I want to disable.
iMash
  • 1,178
  • 1
  • 12
  • 33

1 Answers1

1

Hello i updated the files and i created an array of disabled days please check the code form here

RootViewController.m file http://shorttext.com/l7iKEdf

RootViewController.h file http://shorttext.com/lFaath

just replace these files with the original files from the link you provided you will find that i added a disabledDays NSMutableArray add any integers to it to it like following 0 = sat 6 = friday and that day will be disabled

Omar Abdelhafith
  • 21,163
  • 5
  • 52
  • 56
  • if it was a satisfying answer, please dont forget to accept :) – Omar Abdelhafith Jun 01 '12 at 07:23
  • 1
    Nice work. One line I have changed in your code [disabledDays addObject:[NSNumber numberWithInt:1]]; Instead of put 2 I used 1 because using 2 it give me monday ans saturday and using 1 gives me saturday and sunday. but now one new bug raised that is for september and december 2012 it disable sunday and monday not saturday and sunday. Just wanted to inform you what is this happening. – iMash Jun 01 '12 at 07:36
  • 1
    Yes i saw the bug, ok i temporarily fixed it by doing the following find the line int weekOfDayAcc = weekDay; and add the following after it if(weekOfDayAcc == 7) weekOfDayAcc = 0; this fixes the following issue, please dont forget to test it since i didnt have time to optimize or fully test the solution :) – Omar Abdelhafith Jun 01 '12 at 07:41
  • How can we disable next year all date means I want to show only current year date active. – iMash Jun 04 '12 at 13:03