dateByAddingComponents:toDate:options:
コンポーネントに指定した日付を加えたNSDateを返します
-(NSDate *)dateByAddingComponents:(NSDateComponents *)comps:
toDate:(NSDate *)date:
options:(NSUInteger)opts:
解説
コンポーネントに指定した日付を加えたNSDateを返します。
範囲外であったり、計算できなかった場合にはnilを返します。
返り値
( NSDate * )
なし
フレームワーク
Foundation
クラス
NSCalendar
Instance Methods
使用可能
10.4
参照
-dateFromComponents:
-components:fromDate:toDate:options:
例文
NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease]; [comps setDay:6]; [comps setMonth:5]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDate *currentDate = [NSDate date]; NSDate *date1 = [calendar dateByAddingComponents:comps toDate:currentDate options:0]; NSLog([date1 description]);