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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:29:09+00:00 2026-05-23T13:29:09+00:00

Basically my view controller has 49 different instance variables of class CircleView (called circleView1

  • 0

Basically my view controller has 49 different instance variables of class CircleView (called circleView1, circleView2, …, circleView49). The CircleView class is a simple subclass of UIImageView and basically returns a circle picture when initialized.

Here is what I am trying to do:

In my implementation for the view controller, I want to be able to select the instance variable using a string, for example let’s say I generate a random integer i between 1 and 49, lets say it’s 5. I would like to be able to build an NSString using something like [NSString stringWithFormat @"circleView%i",i]; and somehow reach the actual circleView5 instance variable. Is this possible?

P.S. I’m looking for something in the lines of NSClassFromString, but which applies to instance variables or objects.

  • 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-23T13:29:09+00:00Added an answer on May 23, 2026 at 1:29 pm

    KVC is your friend. Assuming you have a string with the name of the circleView in it,

    NSString *myCircle = [NSString stringWithFormat:@"circleView%i", i];
    

    you access that property on the controller using KVC:

    CircleView *theCircle = [self valueForKey:myCircle];
    

    On a side note, you should consider redesigning the object heirarchary; this will be very difficult to maintain, and there are certainly better ways to do it (an array with the CircleView’s accessed by index would be my first choice).

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

Sidebar

Related Questions

so basically in my app delegate i have a navigation.controller This navigation controller has
I have a root view controller which has few buttons. On click of these
I've got an app that has two parts. Basically, the first part shows a
I am trying to replicate the iPad passcode view. Which basically is a popover
I have a UINavigationController , and push from the root view controller to the
I have a controller which has a few actions, which are triggered by hitting
Do you need to create a seperate xib for a table view controller? For
I've got an MVC controller that stores an object in Session. Different controller actions
I have a site that has different features and functionality based on the location
Basically what I want to do it this: a pdb file contains a location

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.