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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:48:37+00:00 2026-05-17T00:48:37+00:00

At some point in a code one may add something like [[NSNotificationCenter defaultCenter] addObserver:self

  • 0

At some point in a code one may add something like

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomething) name:@"Hello" object:nil];   

How do I test if this notification is already active on the queue or has been removed, to prevent adding a duplicate?

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-17T00:48:37+00:00Added an answer on May 17, 2026 at 12:48 am

    If you mean “testing for whether you’ve already registered as an observer for the notification”, I don’t think there’s an easy way apart from posting the notification and seeing you get a callback (with possibly disastrous effects).

    If there’s a danger of a double-add, I usually use [[NSNotificationCenter defaultCenter] removeObserver:self name:foo object:bar] before the add.

    Registering for notifications does not happen on a queue.

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

Sidebar

Related Questions

If some one can point me in the right direction for this code for
I am working with some legacy code, and at some point there is a
Possible Duplicate: Calculate age in JavaScript In some point of my JS code I
Can anyone point me towards some good documentation / code examples on how best
The following code snippet generates some warning messages when compiling: Cluster& Myclass::getCluster(const Point &p)
Today I was tracking down a floating point exception in some code I had
I've seen some code such as: out.println(print something); I tried import java.lang.System; but it's
I am migrating my PHP code to Ruby and at some point I need
I have some python code that may result in a division by 0, but
So far I have managed to write some code that should print the source

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.