How to check NSString to date
How can I check NSString is date or not? For example:
NSString - Jul 14 at 14.55 PM return TR开发者_Python百科UE
NSString - Talala... return False
Please help..
Assuming you're on iOS you can check that using NSDataDetector
You could use a NSDateFormatter and allow it to use an heuristic to determine if the given input string is a date or not (just call [formatter setLeninent:YES] for this).
If it can create a NSDate object out of your NSString, congratulations, the string contains a date, otherwise it most likely doesn't.
You can try creating a new NSDate instance giving the NSString and check wether the result is nil or not.
NSDate
加载中,请稍侯......
精彩评论