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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:03:21+00:00 2026-05-27T17:03:21+00:00

I have a label that serves as a warning when certain conditions are not

  • 0

I have a label that serves as a warning when certain conditions are not met. But when I attempt to set the label to hidden with the following code:

infoWarning.hidden = YES;

for context, here is the full code:

if (weightC < 50 || (waistM1 < 20 && waistM2 < 20 && waistM3 < 20) || (ageC < 18 )) 
{
    infoWarning.hidden = NO;

    NSString *warning = @"";
    if(ageC < 18)
    {
        warning = @" an age over 17";
    }
    if (averageWaistM < 20) {
        if (warning != @"") {
            warning = [NSString stringWithFormat:@"%@, and", warning];
        }
        warning = [NSString stringWithFormat:@"%@ a waist measurement", warning];
    }
    if (weightC < 50) {
        if (warning != @"") {
            warning = [NSString stringWithFormat:@"%@, and", warning];
        }

        warning = [NSString stringWithFormat:@"%@ a weight", warning];

    }


    if (warning!=@"") {
        [infoWarning setText:[NSString stringWithFormat:@"Please add%@.", warning]] ;
    }


} else {
    if(gender.selectedSegmentIndex == 0)
    {

    }

    else if(gender.selectedSegmentIndex == 1)
    {

    }
}

That I thought would work, but (obviously) does not. It gives me an EXC_BAD_ACCESS error on the line:

infoWarning.hidden = YES;

infoWarning does exist, is synthesized, and is connected to the UILabel in Interface Builder. Could you help me identify the problem and make it work?

This is the .h file:

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@class Preferences;
@class Utilities;


@interface BodyFatCalculatorViewController : UIViewController {

    IBOutlet UITextField *age;
    IBOutlet UITextField *waist1;
    IBOutlet UITextField *waist2;
    IBOutlet UITextField *waist3;
    IBOutlet UITextField *weight;

    IBOutlet UILabel *waist;
    IBOutlet UILabel *currentWeight;

    IBOutlet UILabel *bodyFat;
    IBOutlet UILabel *averageWaist;
    IBOutlet UILabel *veryLean;
    IBOutlet UILabel *veryLeanBorder;
    IBOutlet UIImageView *veryLeanCheckmark;
    IBOutlet UILabel *fit;
    IBOutlet UILabel *fitBorder;
    IBOutlet UIImageView *fitheckmark;
    IBOutlet UILabel *average;
    IBOutlet UILabel *averageBorder;
    IBOutlet UIImageView *averageCheckmark;
    IBOutlet UILabel *atRisk;
    IBOutlet UILabel *atRiskBorder;
    IBOutlet UILabel *atModRisk;
    IBOutlet UILabel *atModRiskBorder;
    IBOutlet UILabel *atHighRisk;
    IBOutlet UILabel *atHighRiskBorder;

    IBOutlet UILabel *infoWarning;

    IBOutlet UISegmentedControl *gender;

    NSMutableArray *arrayAge;
}

@property (nonatomic, retain) IBOutlet UITextField *age;
@property (nonatomic, retain) IBOutlet UITextField *waist1;
@property (nonatomic, retain) IBOutlet UITextField *waist2;
@property (nonatomic, retain) IBOutlet UITextField *waist3;
@property (nonatomic, retain) IBOutlet UITextField *weight;

@property (nonatomic, retain) IBOutlet UILabel *waist;
@property (nonatomic, retain) IBOutlet UILabel *currentWeight;

@property (nonatomic, retain) IBOutlet UILabel *bodyFat;
@property (nonatomic, retain) IBOutlet UILabel *averageWaist;
@property (nonatomic, retain) IBOutlet UILabel *veryLean;
@property (nonatomic, retain) IBOutlet UILabel *veryLeanBorder;
@property (nonatomic, retain) IBOutlet UIImageView *veryLeanCheckmark;
@property (nonatomic, retain) IBOutlet UILabel *fit;
@property (nonatomic, retain) IBOutlet UILabel *fitBorder;
@property (nonatomic, retain) IBOutlet UIImageView *fitCheckmark;
@property (nonatomic, retain) IBOutlet UILabel *average;
@property (nonatomic, retain) IBOutlet UILabel *averageBorder;
@property (nonatomic, retain) IBOutlet UIImageView *averageCheckmark;
@property (nonatomic, retain) IBOutlet UILabel *atRisk;
@property (nonatomic, retain) IBOutlet UILabel *atRiskBorder;
@property (nonatomic, retain) IBOutlet UILabel *atModRisk;
@property (nonatomic, retain) IBOutlet UILabel *atModRiskBorder;
@property (nonatomic, retain) IBOutlet UILabel *atHighRisk;
@property (nonatomic, retain) IBOutlet UILabel *atHighRiskBorder;

@property (nonatomic, retain) IBOutlet UILabel *infoWarning;

@property (nonatomic, retain) IBOutlet UISegmentedControl *gender;

-(IBAction)valueChanged:(id)sender;
-(IBAction)textFieldDoneEditing:(id)sender;
-(void)calculate;


@end

Problem has been fixed, thank you to those who responded and looked into it. The problem was actually an array with the limits that were too small (I don’t know why that caused this to break, they weren’t at all related…) and so I increased the limits and now the infoWarning works great.

  • 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-27T17:03:22+00:00Added an answer on May 27, 2026 at 5:03 pm

    The complete error from the console might help but given “EXC_BAD_ACCESS error” in the line

    infoWarning.hidden = NO;
    

    suggests that there is a problem with infoWarning.hidden, what are the @property and @synthesize statements?

    To compare the contents of strings use:

    [warning is equalToString:@""]
    

    not:

    warning != @""
    

    which compares the pointers to the strings.

    But in your case why not just use:

    warning.length != 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that works on my IIS 5.1 dev box, but not
I have a label that is sometimes empty. How do I set up a
Have the following code which (resides in a dialog box) and serves as an
I have a series of controls, but mostly textboxes and labels that need to
I have a label that is using a repeater to get information form a
I have a label on a splash screen that is displayed for 4 seconds.
I've got a multiline textBox that I would like to have a label on
i have this crazy label for each time i create a migration that use
I have panel that is using group layout to organize some label. I want
I have a composite control that adds a TextBox and a Label control to

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.