Help us understand the problem. What is going on with this article?

逆引きReactiveCocoa: 毎時0分に処理を行う

More than 5 years have passed since last update.

元ネタ: ios - Perform action on the hour, every hour, with ReactiveCocoa - Stack Overflow


現在時刻から1時間毎だと毎時0分とならないので、まずは次の時までの分を得ておきます。

NSDateComponents *components = [[[NSCalendar sharedCalendar] calendar] components:NSMinuteCalendarUnit fromDate:[NSDate date]];
NSInteger minutesToNextHour = 60 - components.minute;

いったん現在時刻から次の時までのタイマーシグナルを生成し、1回限りで終了させた後に改めて60分間隔のタイマーシグナルを繋げて完成です。

RACSignal *updateEventSignal = [[[RACSignal
    // `+interval:`の引数は`NSTimeInterval`で秒単位。
    interval:(60 * minutesToNextHour)]
    take:1]
    concat:[RACSignal interval:3600]];
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした