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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:43:37+00:00 2026-06-16T13:43:37+00:00

I have a UISwitch that on Value Change, hides or unhides some UIButtons with

  • 0

I have a UISwitch that on Value Change, hides or unhides some UIButtons with an if statement. I would like the hidden state of the UIButtons to be saved when I switch views or exit the app. I have tried using NSUserDefaults but it does not save, it just reverts back to the state I had originally set in the .storyboard

.m code:

- (IBAction)buttonHidden:(id)sender {

NSUserDefaults *Defaults = [NSUserDefaults standardUserDefaults];
[Defaults setBool:china.hidden forKey:ChinaChanged];
[Defaults setBool:japan.hidden forKey:JapanChanged];
[Defaults setBool:french.hidden forKey:FrenchChanged];
[Defaults setBool:spanish.hidden forKey:SpanishChanged];
[Defaults synchronize];

}

.m viewDidLoad code:

- (void)viewDidLoad {

[super viewDidLoad];

NSUserDefaults *Defaults = [NSUserDefaults standardUserDefaults];
china.hidden = [Defaults boolForKey:ChinaChanged];
japan.hidden = [Defaults boolForKey:JapanChanged];
french.hidden = [Defaults boolForKey:FrenchChanged];
spanish.hidden = [Defaults boolForKey:SpanishChanged];

}

I do not know where I can connect the IBAction to make it work.

This is my if statement code for the UISwitch:

(IBAction)switchTheSwitch:(id)sender {
if (Languages.on) {
    china.hidden = NO;
    japan.hidden = NO;
    french.hidden = NO;
    spanish.hidden = NO;
}

else {
    china.hidden = YES;
    japan.hidden = YES;
    french.hidden = YES;
    spanish.hidden = YES;

    }
}

Can anyone help me.

  • 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-16T13:43:39+00:00Added an answer on June 16, 2026 at 1:43 pm

    im not sure I follow but to me it seems all you lack is a call to buttonHidden so that defaults get actually saved

    just do

    -(IBAction)switchTheSwitch:(id)sender {
        if (Languages.on) {
            china.hidden = NO;
            japan.hidden = NO;
            french.hidden = NO;
            spanish.hidden = NO;
        }
        else {
            china.hidden = YES;
            japan.hidden = YES;
            french.hidden = YES;
            spanish.hidden = YES;
        }
        [self buttonHidden:sender];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this observer that watches the UISwitch for a change in value: [cell.switcher
I have taken UISwitch from interface builder. That time it's state is ON.After run
I have a TableViewCell with a UISwitch in accessoryView. I don't want that blue
I have made a game which has a UISwitch that turns the music off.
I have a UITableView with cells that contain a UISwitch control. It's similar to
I have a UISwitch that is defined in an .xib file. The event that
I have a simple problem. I created a custom UITableViewCell that includes a UISwitch
I have a UISwitch that sets a BOOL to 1 or 0 in CoreData.
i have a very simple table with only one row that has a uiswitch
I've set up a UITableView with several custom UITableViewCell's that have some UITextField's and

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.