Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,我需要检查用户是否年满 18 岁。我为他提供了 UIDatePickerView,他选择了他的生日日期。我将它存储在 NSDate 字段中。如何查看他的生日是否已经过去了 18 年?
应该这样做:
NSTimeInterval interval = [birthday timeIntervalSinceNow]; if (interval > 18*365*24*60*60) { NSLog(@"You're more than 18"); }