How to set time on NSDate?
问题 I want to set the NSDate time with my desired hours:minutes:seconds currently im working with NSDate component but it is not giving the desired result [comps setHour: -hours]; [comps setMinute:0]; [comps setSecond:0]; NSDate *minDate = [calendar_c dateFromComponents:comps]; 回答1: Your approach should work fine. I needed a solution for this type problem (setting the individual date components) and the following code works as expected for me. My situation: I wanted to create a date object that