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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:01:50+00:00 2026-05-31T22:01:50+00:00

This is my code, which occurs 48 times (one for each button in a

  • 0

This is my code, which occurs 48 times (one for each button in a calendar).

calenderButton *a1 = [calenderButton buttonWithType:UIButtonTypeCustom];
[a1 makeFrame:CGRectMake(75, 50, 70, 70) number:1 color:[UIColor orangeColor]];
[self.view addSubview:a1];

What I want to do is put this in a “for loop”, changing the “a1” to “a2”, “a3”, etc, to cut down on the amount of code. I figure I can cut it down to 6 “for loops”.

How do I get the “a1″s to be a variable that I can then reference in not only the code above but in the “for loop”? (the for loop would be something like this:)

for(int i = 0, j=75; i < 7; i++, j+=75);

I know I have to concatenate the “a” with the integer “i”, but how do I place that in the message?

  • 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-31T22:01:52+00:00Added an answer on May 31, 2026 at 10:01 pm

    You can put your buttons into an array, like this:

    Declare an instance variable NSMutableArray *allButtons in your header, then…

    allButtons = [NSMutableArray array];
    for(int i = 0, j=75; i < 7; i++, j+=75) {
        calenderButton *cb= [calenderButton buttonWithType:UIButtonTypeCustom];
        // Configure the button here...
        // use values of i and j to call CGRectMake, or as you see fit
        [allButtons addObject:cb];
    }
    

    Now all your buttons are in an array. You can access them by index or in any other way that you may need, e.g. with a fast enumeration loop.

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

Sidebar

Related Questions

I have this code which will include template.php file from inside each of these
I have a code in production which crash one/two times per day, since one
I use this code which is taken from MVC futures and attach the Attribute
I have this code which is called at an onChange event of an function
I have this code which gets WP posts, but it gets all the posts
I have this code (which is way simplified from the real code): public interface
I have this code which compiles and works as expected: class Right {}; class
I have this code which should create a splash image with either no animation
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as
So I have this code which is called in a print_info() function after a

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.