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 4118434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:57:37+00:00 2026-05-20T22:57:37+00:00

Need help with a problem. Goal I’m putting together an iOS book app that

  • 0

Need help with a problem.

Goal
I’m putting together an iOS book app that uses NSTimers to fire off several staggered animation events after loading a view. I’ve created a MethodCallerWithTimer class to help me do this (code at bottom).

My Solution So Far
When I use the MethodCallerWithTimer class, I assign the objectOwningMethod as my UIViewController subclass object (it’s a book page), and then the method as an instance method in that class. Here is an example of a method I assign – quite simply turning on some artwork on the screen:

- (void) playEmory {
   [emoryRedArt setHidden:NO];
}

My Issue
When I create multiple MethodCallerWithTimer instances then load the view and start them all, I only ever get the FIRST event to happen. None of the other timers call their target methods. I suspect I don’t understand what I’m asking NSRunLoop to do or something similar.

Any thoughts?

Here is my MethodCallerWithTimer class:

@interface MethodCallerWithTimer : NSObject {
    NSTimer * timer;
    NSInvocation * methodInvocationObject;
    NSNumber * timeLengthInMS;
}

- (id) initWithObject: (id) objectOwningMethod AndMethodToCall: (SEL) method;
- (void) setTime: (int) milliseconds;
- (void) startTimer;
- (void) cancelTimer;

@end

And implementation:

#import "MethodCallerWithTimer.h"

@implementation MethodCallerWithTimer

- (id) initWithObject: (id) objectOwningMethod AndMethodToCall: (SEL) method {
    NSMethodSignature * methSig = [[objectOwningMethod class] instanceMethodSignatureForSelector:method];
    methodInvocationObject = [NSInvocation invocationWithMethodSignature:methSig];
    [methodInvocationObject setTarget:objectOwningMethod];
    [methodInvocationObject setSelector:method];
    [methSig release];
    return [super init];
}
- (void) setTime: (int) milliseconds {
    timeLengthInMS = [[NSNumber alloc] initWithInt:milliseconds];
}
- (void) startTimer {
    timer = [NSTimer scheduledTimerWithTimeInterval:([timeLengthInMS longValue]*0.001) invocation:methodInvocationObject repeats:NO];
}
- (void) cancelTimer {
    [timer invalidate];
}
-(void) dealloc {
    [timer release];
    [methodInvocationObject release];
    [timeLengthInMS release];
    [super dealloc];
}

@end
  • 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-05-20T22:57:37+00:00Added an answer on May 20, 2026 at 10:57 pm

    These look like one-time firings after a delay; have you considered using something like:

    [myObject performSelector:@selector(playEmory) withObject:nil afterDelay:myDelay];
    

    where myObject is the instance with the playEmory routine and myDelay is a float of the seconds you want the OS to wait before making the call?

    You can find out more information about this flavor of performSelector here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem, i'm working on a gallery php script and need help,
I need some help regarding algorithm for randomness. So Problem is. There are 50
I really need help with interfaces in general... Any resources that you guys would
I'm stuck on a problem and if possible I will need help from the
I need some help in understanding a python concept. class TilePuzzleProblem(search.Problem): This class is
I need help solving problem N from this earlier competition : Problem N: Digit
Need help with this SQL Server 2000 procedure. The problem is made difficult because
I need help to create a regex (for JavaScript .match and PHP preg_match) that
Goal: Website1 sends Website2 user data through http requests. Problem: Website2 is ensured that
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat

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.