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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:55:08+00:00 2026-05-11T15:55:08+00:00

How can I get a list (in the form of an NSArray or NSDictionary

  • 0

How can I get a list (in the form of an NSArray or NSDictionary) of a given object properties in Objective-C?

Imagine the following scenario: I have defined a parent class which just extends NSObject, that holds an NSString, a BOOL and an NSData object as properties. Then I have several classes which extend this parent class, adding a lot of different properties each.

Is there any way I could implement an instance method on the parent class that goes through the whole object and returns, say, an NSArray of each of the (child) class properties as NSStrings that are not on the parent class, so I can later use these NSString for KVC?

  • 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. 2026-05-11T15:55:09+00:00Added an answer on May 11, 2026 at 3:55 pm

    I just managed to get the answer myself. By using the Obj-C Runtime Library, I had access to the properties the way I wanted:

    - (void)myMethod {     unsigned int outCount, i;     objc_property_t *properties = class_copyPropertyList([self class], &outCount);     for(i = 0; i < outCount; i++) {         objc_property_t property = properties[i];         const char *propName = property_getName(property);         if(propName) {             const char *propType = getPropertyType(property);             NSString *propertyName = [NSString stringWithCString:propName                                                                 encoding:[NSString defaultCStringEncoding]];             NSString *propertyType = [NSString stringWithCString:propType                                                                 encoding:[NSString defaultCStringEncoding]];             ...         }     }     free(properties); } 

    This required me to make a ‘getPropertyType’ C function, which is mainly taken from an Apple code sample (can’t remember right now the exact source):

    static const char *getPropertyType(objc_property_t property) {     const char *attributes = property_getAttributes(property);     char buffer[1 + strlen(attributes)];     strcpy(buffer, attributes);     char *state = buffer, *attribute;     while ((attribute = strsep(&state, ',')) != NULL) {         if (attribute[0] == 'T') {             if (strlen(attribute) <= 4) {                 break;             }             return (const char *)[[NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4] bytes];         }     }     return '@'; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a pretty basic form app. I can get a list of
I have one table having ID and other attributes. How can I get list
i have a form and a sortable() list where a user can drag from
How can I get all list elements having a <span> element with class=required <form
I have a HTML form with a drop down list. I want to get
How can i get index of generic list from form page? For example; aspx.cs
I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to
You can get a list of databases using PRAGMA database_list or a list of
There's a function in PHP where you can get a list of the user
Is there any debugging options built-in in the Xlib (libX11.so)? Can I get list

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.