Combing NSString with the day of week and NSDate with the time into an NSDate object?

Up vote 1 down vote favorite share g+ share fb share tw.

I have the following two objects: An NSString object with a day of the week, ie Monday, Tuesday, Wednesday, etc. An NSDate object that was saved from a UIDatePicker with UIDatePickerModeTime. I need to create a third object, NSDate that is the next occurance of the NSString with the time from the NSDate. //Ex.

Tuesday NSString *confessOn = NSUserDefaults standardUserDefaults objectForKey:kRemindToConfessOn; //Ex. 2011-02-11 20:13:19 NSDate *confessAt = NSUserDefaults standardUserDefaults objectForKey:kRemindToConfessAt; NSDate *fireDate = //should be an NSDate with the value 2011-02-15 20:13:19 objective-c cocoa-touch nsdate uidatepicker uidatepickermodetime link|improve this question asked Feb 13 '11 at 10:10Travis1,453417 71% accept rate.

NSDateFormatter * df = NSDateFormatter alloc init autorelease; df setLocale:NSLocale alloc initWithLocaleIdentifier(@"en") autorelease; df setDateFormat:@"EEEE"; NSDate *confessOnDate = df dateFromString:confessOn; NSCalendar *cal = NSCalendar alloc initWithCalendarIdentifier:NSGregorianCalendar autorelease; NSDateComponents *confessOnComps = cal components:NSWeekdayCalendarUnit fromDate:confessOnDate; NSDateComponents *confessAtComps = cal components:NSWeekdayCalendarUnit fromDate:confessAt; NSInteger weekdayDifference = (confessOnComps weekday + 7 - confessAtComps weekday) % 7; NSDate *fireDate = confessAt dateByAddingTimeInterval:weekdayDifference * 86400.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions