Search code examples
objective-cnsarraynsdatenstimernstimeinterval

How compare the user actual time with a NSArray?


I have a NSArray with many different hours as NSStrings. My question is, how can I compare the actual time of the user with the values into the NSArray and get which is the next hour to the actual user? For example, if the NSArray has got @"07:00", @"07:30", @"08:00", and now it's 07:40, how can I achieve that the app returns 08:00 as the next hour?? Maybe with NSTimers??

I know it's hard to understand thus many thanks.


Solution

  • Lookup NSDate , after you've read that you might find NSDateComponents and NSDateFormatter useful. The rest is programming... If you get stuck ask another question giving the code you've produced and the problem you are having.

    HTH