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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:19:48+00:00 2026-06-16T02:19:48+00:00

I register for being notified in superclass (UIViewController) like so: SuperClass.m – (void)viewWillAppear:(BOOL)animated {

  • 0

I register for being notified in superclass (UIViewController) like so:

SuperClass.m

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(notification:)
                                                 name:@"Notification"
                                               object:nil];
}

- (void)notification:(NSNotification *)notification {

    // Do something for SuperClass with the notification
}

Now In subclass (subclass of SuperClass.m) I also listen for the same notification like so:

SubClass.m

- (void)notification:(NSNotification *)notification {

    // Do something specific for SubClass with the notification
}

Is this an acceptable (codewise) way to deal with having a general behaviour when acting on a notification in a superclass and to having a more specific behaviour when acting on a notification in a subclass?

  • 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-16T02:19:49+00:00Added an answer on June 16, 2026 at 2:19 am

    Usually when you want to allow more specific behavior in the subclass, while still maintaining the general behavior in the superclass, you have the subclass call super. For example, the -[UIViewController viewDidAppear:] documentation says:

    You can override this method to perform additional tasks associated with presenting the view. If you override this method, you must call super at some point in your implementation.

    So your notification setup is fine (although it’s a bit weird to have a NSNotification object as a parameter to a method you expect to be overridden) — but you’ll want to call [super notification:notification] to get the superclass’s behavior as well.

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

Sidebar

Related Questions

Whenever I see it being talked about, it sounds like one simply 'turns on'
i've learned that you can register body onload like this: window.addEventListener('load', function, capture); //
In a log-in/register box I have to separate two buttons with a text like
I am trying to register my app as being able to open text files.
I would like to register a class (not an instance) when it's created... but
Query is running however not being sent to SQL server. My Current Register Script.
You system allows new users to register and enter their wedding date. Being a
I try to register if a key has been toggled on or off like
I register a UPnP device with: var o: IUPnPRegistrar; W: string; R: HRESULT; begin
Code @register.inclusion_tag('template.html', takes_context=True) def include_client_side_bar(context): return { 'STATIC_URL': settings.STATIC_URL, } My code is will

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.