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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:13:35+00:00 2026-06-11T19:13:35+00:00

In an implementation of a CGRect, I attempt this: BOOL didStartPressing = NO; if

  • 0

In an implementation of a CGRect, I attempt this:

BOOL didStartPressing = NO;
if ( didStartPressing) {int nmax=5;}
else{int nmax=500;}

for (int n=1; n<nmax; n=n+1){ *... working code that draws some circles ....*     }

This gives yellow warnings about “unused variable nmax” in the first part above
and red warnings about “use of undeclared variable nmax.” for the for loop.
If however I simply replace the first three lines above with

int nmax=500; 

I get a lovely picture that I drew in CGRect.

Greatest of thanks for help, as I’m complete noob up against the hard wall of learning curve.

  • 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-11T19:13:36+00:00Added an answer on June 11, 2026 at 7:13 pm

    You’ve limited the scope of nmax to the braces after the if and the else. So you have two variables with that name, neither of which is visible to the for loop. To solve, move the declaration to the outer scope and simply assign to the variable in the if/else scopes:

    int nmax = 0;   // the = 0 is optional in this case because all code
                    // paths assign a value to nmax
    BOOL didStartPressing = NO;
    if (didStartPressing) {
        nmax=5;
    } else {
        nmax=500;
    }
    
    for (int n=1; n<nmax; n=n+1) {
        /*... working code that draws some circles ....*/
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the tableView:cellForRowAtIndexPath: implementation of my UITableViewController subclass I'm using this code snippet: AlarmPicker
i have the following code to customize UINavigationController : @implementation UINavigationBar (UINavigationBarCategory) - (void)drawRect:(CGRect)rect
I've made a custom uinavigation bar this way: @implementation UINavigationBar (UINavigationBarCategory) - (void)drawRect:(CGRect)rect {
Is there some way I can do something like: @implementation MyView - (void)drawRect:(CGRect)rect {
My implementation for UIDatePicker is essentially this one . My problem is that if
The implementation of Enumerable.AsEnumerable<T>(this IEnumerable<T> source) simply returns source . However Observable.AsObservable<T>(this IObservable<T> source)
I have a c++ implementation file (my.cpp) that indirectly includes a header file (b.h)
Having some problems with customizing the UINavigationController. The size change is working, but the
I set the header in my CustomTabBarViewController @implementation UINavigationBar (UINavigationBarCategory) - (void)drawRect:(CGRect)rect { CGContextRef
I used custom navigation bar within my application, // appdelegate.h @implementation UINavigationBar(customNavBar) - (void)drawRect:(CGRect)rect{

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.