LoginSignup
11
11

More than 5 years have passed since last update.

引数にNSDateが有るけど実質的には無視したい、あるいは適当な値を放り込みたい時

Posted at

nilが許可されてるならnilでも良いが、それでは駄目なとき。
[NSDate distantFuture]を使う事で解決できるケースがある。
このメソッド自体はデフォルトの状態では”4001-01-01 00:00:00 +0000”と遙か未来の値を返します。

例えば、指定したNSDateまでの間イベント待ちをするといったメソッドで、アプリを起動している間無制限に待ちたいときなどに[NSDate distantFuture]を使います。

NSDateSample
@implementation NSDateSample

- (NSDate *)dateSample {
    return [NSDate distantFuture];
}

@end

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11