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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:55:18+00:00 2026-06-04T22:55:18+00:00

Im working on an ios app, ios 5+ , using xcode and objective c.

  • 0

Im working on an ios app, ios 5+ , using xcode and objective c. Ok currently messing with nsnotifications and i just need some clarifications as im a wee bit confused.
Lets say i have a view controller that i add an observer to like so

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showContent:) name:kTPSShowContentNotification object:self];

where the object is set to self. I took this to mean that it is only looking from that notification if sent from that object. am i wrong on that?

elsewhere in code I am positing a notification like so

 [[NSNotificationCenter defaultCenter] postNotificationName:kTPSShowContentNotification object:currentVC];

where currentVC is the view controller that has the observer set up initially.
I thought this is all that was needed to catch that notification as the post is telling the notification center to send it from that view controller. but it fails to catch it and im unsure as to why. If when adding the observer i set the object as nil then it catches it but so does all the other viewcontrollers (if any ) that have observers for that notification too. Is there any way around this ? am i approaching this completely wrong?

  • 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-04T22:55:19+00:00Added an answer on June 4, 2026 at 10:55 pm

    If I’m getting this right, you want to post and get a notification from the same controller. So you can do something like this:

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showContent:) name:kTPSShowContentNotification object:self];
    
     [[NSNotificationCenter defaultCenter] postNotificationName:kTPSShowContentNotification object:self];
    

    But it should work indeed if your currentVC ivar is pointing to the very same controller. The fact that you say it doesn’t work makes me believe that it is not pointing to the same instance of your controller.

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

Sidebar

Related Questions

I'm developing an iOS app. Its working properly on simulator. I'm using phonegap and
I was developing an app in Xcode and everything was working just fine. I
I was working on a simple game app using Xcode, but when I saw
Short introduction Working on my first commercial iOS app, XCode 3.2 has proven to
I'm currently using XCode 3.2.4 and OS 4.2 It's been working smoothly but now
I'm working on an iOS app and I'm using the following code for one
I'm working on an app using the 4.2 iOS SDK and recently changed the
Im making on an ios app and currently working to get cell deletion from
Ive working on an ios app and i am currently trying to add custom
I have an iOS app that streams background audio using AVAudioSession. It is working

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.