Is there any way/ method to seperate month & year form NSDate?
是否有任何方式/方法来分隔NSDate的月份和年份?
I just need to display current month & year? Any Example?
我只需要显示当前的月份和年份?任何例子?
2 个解决方案
#2
6
NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:date];
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
[calendar release];
cheers endo
#1
#2
6
NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:date];
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
[calendar release];
cheers endo