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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:10:53+00:00 2026-05-18T03:10:53+00:00

Newbie question: Can one substitue commands, properties or methods for NSStrings or char at

  • 0

Newbie question: Can one substitue commands, properties or methods for NSStrings or char at runtime?

Lets say I do something like this:

//these are the names of my properties of an NSObject I created
char theChangingProperty[17][18] = {"name", "title", "number", "property4", "property5", "property6", "property7", "property8", "property9", "property10", "property11", "property12", "property13", "property14", "property15", "property16", "property17"};

(PS I know there is a better actual objective-c way of getting an objects properties, I even found a post with this Get an object properties list in Objective-C)

anyway, how does one iterate through a list and have the property name change? Lets say I’m using dot notation at runtime during a loop… If I wanted to set 17 (or 100!) different properties of my object all to values of some other array all at once, like this:

for (int t=1; t<17; t++) {
    myObject.theChangingProperty[t] = valueOfAnotherArray[t];
}

I know objective-c is going to look for an actual property called “theChangingProperty”. But I want that to be an array that will spit out the actual property that would change with each loop iteration (name, title, number, property4, etc)

Thanks for your time in answering a newbie question 🙂

  • 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-05-18T03:10:54+00:00Added an answer on May 18, 2026 at 3:10 am

    You can use setValue:forKey: but note that property keys need to be NSStrings, not C strings so declare your array:

    NSString* theChangingProperty[17] = { @"name", ....
    

    Then you would write:

    for (int t = 0; t < 17; t++) 
    {
        [myObject setValue: valueOfAnotherArray[t] forKey: theChangingProperty[t]];
    }
    

    Or you can use performSelector:withObject: but then your array needs to contain selectors

    SEL theChangingProperty[17] = { @selector(setName:), ....
    
    for (int t = 0; t < 17; t++) 
    {
        [myObject performSelector: theChangingProperty[t] withObject: valueOfAnotherArray[t]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for this newbie question, but I can't find on google what I need
this is a bit of a newbie question but hoping I can get some
As a newbie question, granted that a switch statement could be used, can the
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
SSRS newbie question here... I have a table where one column is varbinary(max) data.
Just a newbie question really. Can you edit a website (in Visual Studio) on
Sorry fot his newbie question. But I really need a start on this one.
Rails newbie question that I can't seem to figure out. At some point I
Sorry for the incredibly newbie question, but I can see myself drifting into bad
Sorry for the newbie question, but I can't seem to figure this out. I

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.