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

  • Home
  • SEARCH
  • 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 6609845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:45:57+00:00 2026-05-25T19:45:57+00:00

I’ve read around SO as well as looked at the Apple documentation for the

  • 0

I’ve read around SO as well as looked at the Apple documentation for the NSTimer class, and it seems like the easiest way to create a timer is by using the following method:

[NSTimer scheduledTimerWithTimeInterval:15.0
                                 target:self
                               selector:@selector(fireThisMethod:)
                               userInfo:nil
                                repeats:NO];

I understand that this will create a timer that fires after 15 seconds. The method that will be fired will be whatever method is passed into the “selector” (in this case “fireThisMethod”). Since the “repeats” is “NO,” this means that it will only be fired once. My questions are:

1) Is it possible to pass in a method to “selector” that has more than one parameter? I’ve seen methods without any parameters, or in this case 1 (since a “:” is present after the method name). A method such as fireThisMethod:anotherParameter:?

2) I’m not sure if I truly understand what the “target” and “userInfo” parameters are for. Will you ever have a “target” that isn’t “self?” Will you have a “userInfo” that isn’t nil? If so, in what scenarios?

Thanks

  • 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-25T19:45:58+00:00Added an answer on May 25, 2026 at 7:45 pm

    Question 1

    No. Take a look in the docs. Quoting:

    The selector must have the following signature:

    - (void)timerFireMethod:(NSTimer*)theTimer

    Selectors for methods without arguments are wrong. The argument to be passed is
    the timer, so you can do things like distinguishing which timer fired from you
    method (in case more than one timer calls the same method).

    Question 2a

    The target can be any object that implements the given method. Sometimes you may
    want a specific object (other than self) to do the task after the timer fires.

    Question 2b

    This is exactly what you’re looking for. userInfo can be any object, maybe a
    data container, a NSValue, or any other thing. Use this to pass extra
    information to your method which will extract it as follows:

    - (void)timerFireMethod:(NSTimer*)theTimer
    {
        id info = [theTimer userInfo]; /* give it an appropriate type */
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.