Jay*_*Jay 5 cocoa objective-c
只是出于好奇(因为这是我第一次需要在Cocoa中计算它) - 这真的是计算当年最简洁的方法吗?
int thisYear = [[[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:[NSDate date]] year];
看起来很笨拙..
Dan*_*iel 4
是的,当我需要从日期(如日、月或年)获取组件时,我使用NSDateComponents,事实上日期很笨拙 - 有不同的日历、时区、闰年等。
NSDateComponents
归档时间:
13 年 前
查看次数:
2007 次
最近记录: