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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:14:37+00:00 2026-05-17T15:14:37+00:00

Forgive me if this is a simple question, but is a UISwitch a boolean

  • 0

Forgive me if this is a simple question, but is a UISwitch a boolean variable? If it is not, how can I make it BOOL?

Please allow me to explain why I’m having trouble.

I declared my variable in my FlipsideViewController.

UISwitch* mySwitch;     //switch used to turn label2 on/off

also creating an accessor

@property (nonatomic, retain) IBOutlet UISwitch *mySwitch;

EDIT: and of course I synthesize it.

Then in Interface Builder I connected mySwitch to a Switch I created on that view.

NOW, I have a method that I’m using which is this in the MainViewController:

- (void)updateLabels:(NSString *)text :(BOOL)isOn {

    [nameLabel setText:text]; 
    if (isOn==YES)
    [onLabel setText:(@"ON")];
      else
       [onLabel setText:(@"OFF")]; }

The problem I’m having is that whenever I run the program, the label always displays “OFF”. Do you have any clue why? I’m really helpless.

I would really appreciate any help on this, and again I apologize for being such a newbie. 🙂

EDIT: This is how I’m calling the method…

 [self.delegate updateLabels: myTextField.text : mySwitch.state];

So, I’m passing in the state of the mySwitch UISwitch.

  • 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-17T15:14:38+00:00Added an answer on May 17, 2026 at 3:14 pm

    You either need to connect the UISwitch to an IBAction method that updates isOn, or read the state of the switch in your test.

    Here’s the latter: UPDATE Changed the code after you clarified the relationships between the view controllers.

    - (void)updateLabels:(NSString *)text isOn:(BOOL)isOn {
        [nameLabel setText:text]; 
        if (isOn == YES) {
           [onLabel setText:(@"ON")];
        } else {
           [onLabel setText:(@"OFF")]; 
        }
    }
    

    The call to updateLabels, which I’m hoping exists in FlipSideViewController, should look something like this: (I obviously don’t know your variables names.)

    [self.delegate updateLabels:self.myTextField.text isOn:self.mySwitch.on];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive what might seem to some to be a very simple question, but I
I'm new to C#, so forgive this noobish question. I'm playing with a simple
I am not great with anything beyond basic javascript so please forgive the simple
I'm new to jquery and asp.net so please forgive if this is an obvious
I'm trying to learn C++ so forgive me if this question demonstrates a lack
I'm a very novice OCaml programmer so please forgive me if this is a
Forgive me for a potentially silly question here, but in other programming languages (scripting
Please forgive my long question. I have an idea for a design that I
Just a simple question, Im trying to replace class with var, but obviously still
Forgive me if this has been asked before; I did a search but couldn't

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.