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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:33:07+00:00 2026-06-18T22:33:07+00:00

This may be a ridiculous question, but I have a method like this in

  • 0

This may be a ridiculous question, but I have a method like this in my view controller:

[self registerProperty:self.currentUser];

and in the implementation of registerProperty: I would like to get the string “currentUser”.

I’m doing this because I want to observe the property of the view controller “currentUser”, not the actual user object, so I can intercept the setter.

At the moment I’m checking the Objective-C runtime for a list of all properties of the view controller and checking if the value of the property equals the currentUser object:

-(void)registerProperty:(id)property 
{
    for (NSString *propertyName in [self allPropertiesOfClass:[property class]])
        if ([property isEqual:[self valueForKey:propertyName]])
             NSLog(@"The property passed into the method is %@", propertyName);
}

The problem with this is that I may have two properties that both contain the same user object, in which case either of them would pass that test. How could I fix this?

  • 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-18T22:33:08+00:00Added an answer on June 18, 2026 at 10:33 pm

    Pass in the object whose property you want to observe and, separately, the property name as a string. That is, mirror (a subset of) the arguments of the KVO -addObserver:... method.

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

Sidebar

Related Questions

This may sound like a very generic question but here it goes. I have
This may seem like a weird question but thought I would ask here before
This may be a ridiculous question, but it seems like a reasonable one to
This may be a ridiculous Java question about exception handling, but I have a
This may be a ridiculous question, but it's been bothering me for a while.
This may be a stupid question but I have a code with the following
This may seem like a stupid question but I just started learning javascript about
This may be a ridiculous question - but I know nothing about videos, video
This may sound ridiculous but I need to send something like <policy-file-request/> followed by
This may seem like an obvious problem, but I have looked on the facebook

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.