Thursday, 15 August 2013

ios - select/deselect random multiple dates -



ios - select/deselect random multiple dates -

on click want select/deselect random multiple dates. user should able select multiple dates (ex: should able select 2 dec 2014, 8 dec 2014 , 18 dec 2014. these 3 dates should selected.). current m using dlscalendar. dlscalendar supports single date selection , range selection. others lib supports above mention functionality welcome

thanks.

please more precise in want accomplish.

if trying create random dates in objective-c can following:

// objective-c random date picker //set day integers int lowerday = 1; int upperday = 31; //set month integers int lowermonth = 1; int uppermonth = 12; //set year integers int loweryear = 1; int upperyear = 2025; //or random year, higher loweryear! //generate random date int monthvalue = lowermonth + arc4random() % (uppermonth - lowermonth); //month int yearvalue = loweryear + arc4random() % (upperyear - loweryear ); //year //days differ each month should business relationship nsarray *highmonth =@[@"1",@"3",@"5",@"7",@"8",@"10",@"12"]; //months 31 days nsarray *lowmonth =@[@"4",@"6",@"9",@"11"]; //months 30 days nsstring *secondmonth =@"2"; nsstring *random_month =[nsstring stringwithformat:@"%d",monthvalue]; int dayvalue; if ([highmonth containsobject:random_month]) { //do nil upperday correctly set }else if([lowmonth containsobject:random_month]){ upperday=30; }else if([random_month isequaltostring:secondmonth]){ //to options 28 or 29 days if (fmod(monthvalue, 1.0) == 0.0) { //29 days upperday=29; }else{ //28 days upperday=28; } } dayvalue = lowerday + arc4random() % (upperday - lowerday ); //day //create nsdate , give our random numbers nsstring *datestring = [nsstring stringwithformat:@"%d-%d-%d",dayvalue,monthvalue,yearvalue]; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd-mm-yyyy"]; nsdate *datefromstring=[dateformatter datefromstring:datestring]; //check random date if (datefromstring==nil) { nslog(@"could not create random date"); }else{ nslog(@"succes! date was: %@",datefromstring); }

ios objective-c iphone ipad

No comments:

Post a Comment