Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:21:24+00:00 2026-06-14T22:21:24+00:00

I want to implement a countdown timer using Reactive Cocoa in iOS. The timer

  • 0

I want to implement a countdown timer using Reactive Cocoa in iOS. The timer should run for X seconds and do something in every second. The part I cannot figure out is the way I could cancel the timeout.

RACSubscribable *oneSecGenerator = [RACSubscribable interval:1.0];
RACDisposable *timer = [[oneSecGenerator take:5] subscribeNext:^(id x) {
    NSLog(@"Tick");
}];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:21:25+00:00Added an answer on June 14, 2026 at 10:21 pm

    I think, I found the solution. The trick is to merge the cancel signal into the tick signal, then take X samples. The final subscribers will receive a next event every time the tick signal ticks and completed when the ‘take’ is finished. Cancellation can be implemented by sending error on the cancel timer.

    __block RACSubject *cancelTimer = [RACSubject subject];
    RACSubscribable *tickWithCancel = [[RACSubscribable interval:1.0] merge:cancelTimer];
    RACSubscribable *timeoutFiveSec = [tickWithCancel take:5];
    
    [timeoutFiveSec subscribeNext:^(id x) {
        NSLog(@"Tick");
    } error:^(NSError *error) {
        NSLog(@"Cancelled");
    } completed:^{
        NSLog(@"Completed");
        [alert dismissWithClickedButtonIndex:-1 animated:YES];
    }];
    

    To activate cancel, one has to do the following.

    [cancelTimer sendError:nil]; // nil or NSError
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Android Timer for a game. I want to implement a countdown
I want to implement a list of ViewPagers. Every item of a ListView is
I want to implement login using facebook in my windows phone 7.1 application When
I wrote small service class and I want implement something like that : service
I want to implement the replication and fault tolerance in CORBA using Java. I
I'm trying to implement a countdown timer into a pre-existing public class and I
I want to implement SQLite database for iPhone using PhoneGap. I know some basics
I want implement multiple languages in my program. I'm using an xml file like
I want to implement Facebook login using dialog, not by automatic launching of the
I want implement in my software solution an VBA editor but in c# 3.0.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.