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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:43:19+00:00 2026-05-29T23:43:19+00:00

I am trying to create a framework for all of the custom objects and

  • 0

I am trying to create a framework for all of the custom objects and views that I have made and use often, by creating custom delegate classes and custom objects. Everything has gone well except when trying to get NSTimers to call the correct method inside of the delegate class.

Here is the basic setup.

-(void) startTimers {
    NSTimer *timer1 = [NSTimer timerWithTimeInterval:5 target:self selector:@selector(doSomething:) userInfo:nil repeats:YES];
    NSTimer *timer2 = [NSTimer timerWithTimeInterval:5 target:self selector:@selector(doSomethingElse:) userInfo:nil repeats:YES];
}

I can easily just call this method and whatever, but when this time fires it does not call the method I defined as the selector. I am pretty sure it has something to do with the delegate value and which class it is making as the delegate.

Note the file I am writing in is a subclass of UIView, which is set up to be a delegate using the @protocol tags and all of that.

What should I set as the target when defining my timers to get them to call the correct methods.

EDIT:

Here is an example of what I am doing:

ExampleView.h

#import <UIKit/UIKit.h>

@protocol ExampleViewDelegate;

@interface ExampleView : UIView {
    NSTimer *timer;
}
-(void) initWithStuff:(id)stuff andFrame:(CGRect)frame;
-(void) testTimer;
@end

@protocol ExampleViewDelegate

-(void) someDelegateFunction;
@end

ExampleView.m

#import "ExampleView.h"

@implementation ExampleView


-(id) initWithStuff:(id)stuff andFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(testTimer) userInfo:nil repeats:YES];
    return self;
}

-(void) testTimer {
    NSLog(@"Timer Fired");
}

@end

If you add this custom view into a viewcontroller it will never call that testTimer function and print “Timer Fired” So what I am thinking is that when I set the delegate for this timer, it is actually setting it to something else. Any ideas?

  • 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-29T23:43:20+00:00Added an answer on May 29, 2026 at 11:43 pm
    NSTimer *timer1 = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(doSomething:) userInfo:nil repeats:YES];
    

    Notice the method is called “scheduledTimerWithTimeInterval”

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

Sidebar

Related Questions

I'm trying to create a small Javascript framework that I can use in my
I'm trying to create a rails web app that does not use ActiveRecord framework
I have a prob. I'm trying to create a custom slugify functiom. I use
I am trying to extend the partial classes that the entity framework creates so
I'm trying to create a base repository for use with Entity Framework 4.0 and
I am trying to create a pluggable ASP.NET MVC framework. I have extensively used
I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework
I'm now trying to create a xml-rpc server with the CodeIgniter Framework. <?php $this->load->library('xmlrpc');
I'm trying to create a REST service in zend framework. I'm using zend server.
I'm playing with the ASP.NET MVC Framework, trying to create a simple site. My

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.