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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:39:46+00:00 2026-06-02T01:39:46+00:00

I am accessing a dispatched notification like so: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUnpresent:) name:UNPRESENT_VIEW object:nil];

  • 0

I am accessing a dispatched notification like so:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUnpresent:) name:UNPRESENT_VIEW object:nil];

...

-(void)handleUnpresent:(NSNotification *)note;
{
    NSLog(@"%@", note.object.footer);
    //property 'footer' not found on object of type 'id'
}

Some of the incoming note.object objects have a “footer” and some don’t. However, I don’t want to go through to trouble of making a class that only has a property called footer just to make this work. I even tried ((NSObject *)note.object).footer) which works in some languages, but apparently not obj-c. What can I do?

  • 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-02T01:39:48+00:00Added an answer on June 2, 2026 at 1:39 am

    Checking the isKindOfClass is certainly the more robust option. However, if you have multiple unrelated classes that return the property you need, there is another way: respondsToSelector. Just ask if the object has a footer method, and you can safely call it.

    -(void)handleUnpresent:(NSNotification *)note;
    {
        id noteObject = [note object];
        if ([note respondsToSelector:@selector(footer)])
        {
            NSLog(@"Footer = %@", [noteObject footer]);
        }
    }
    

    That respondsToSelector method is powerful and handy in the right places, but don’t go wild with it. Also, it can’t tell you anything about the return type, so the footer you get may not be of the class you were expecting.

    The syntax for noteObject.footer and [noteObject footer] are easy to treat as equivalent. However, when the class of noteObject is unknown, the compiler will accept the latter but not the former. If noteObject has a defined class that doesn’t usually respond to footer, it will give a warning, but still compile and run. In these cases, it is your responsibility to guarantee that the method will indeed exist when needed, and therefore that the method call won’t crash at run time.

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

Sidebar

Related Questions

When accessing member that doesn't exist, automatically creates the object. $obj = new ClassName();
when accessing foo() of base using derived class's object. #include <iostream> class base {
Accessing private transient object fields from any method in class must be controlled with
When accessing an element in an array the square brackets are used like so:
Accessing Tables by Name I need to reference a table name by a string
When accessing an object in a DataTable retrieved from a database, are there any
Accessing map inside map with closure, I have a map object the values is
When accessing the winapi method CloseHandle() via .net P/Invoke, should the argument be IntPtr
Can accessing (for read only) memory freed cause an access violation, and, if so,
While accessing our own website in Java code, an exception is thrown: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:

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.