2011-08-25 1 views

答えて

15

はそれを行うための一つの方法である:

NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease]; 
[components setDay:-1]; 

NSDate *yesterday = [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:[NSDate date] options:0]; 

Date and Time programming guideを見てみましょう。

+0

負数を減算しない1日追加する? – honcheng

+2

メソッドdateByAddingComponents *が* – progrmr

+0

@progrmrを追加しました。ありがとうございます。 –

関連する問題