Determine if current local time is between two times (ignoring the date portion)

后端 未结 3 449
礼貌的吻别
礼貌的吻别 2021-01-06 05:59

Considering that there is no NSTime in Cocoa-Touch (Objective-C on iPhone), and given two times as NSStrings and a timezone as an NSString, how can you calculate whether or

3条回答
  •  清酒与你
    2021-01-06 06:07

    You should be able to do what you are wanting to do with a combination of NSDate, and NSDateFormatter.

    NSDateFormatter has a dateFromString: method which will let you convert your strings into NSDate objects, then you can use the compare: method of NSDate to compare the two against [NSDate date] which will have the current time.

    (NSDate encompasses both date and time)

提交回复
热议问题