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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:22:40+00:00 2026-06-13T02:22:40+00:00

Still pretty new to ObjectiveC and Cocoa here. Hopefully the answer to this question

  • 0

Still pretty new to ObjectiveC and Cocoa here. Hopefully the answer to this question is straight forward but not painfully obvious.

I’ve got a simple application that uses a couple text fields to setup a couple of strings that are searched for a string in a third text field and the result is displayed in a label. For this exercise I’m using the -rangeOfString method of NSString. To make things more fun I decided to add a checkbox to do case sensitive searches.

That all works great except one thing: The state of the checkbox and the BOOL it “controls” are out of sync when the application starts. In IB the checkbox state is set to on. The target of the checkbox’s action is a method -(IBAction)checkboxChange which evaluates the checkbox state and sets a BOOL accordingly. The BOOL is created with a value of NO.

Currently I’ve got a line of code in -awakeFromNib that sets the BOOL to YES. What I’m after is a way to have the checkbox send it’s action when the application is loaded so the BOOL is set consistent with the checkbox state. I thought I could use -applicationDidFinishLoading in AppDelegate but I don’t know how I’d refer to the checkbox there. I also thought I could set the value of the BOOL in that method but even though I’ve imported the .h file where the BOOL is defined XCode complains the identifier is undefined.

And should it be relevant, all my code is in a class named AppController and I’m not using the default AppDelegate at all.

Thanks for reading and for your suggestions / answers!

  • 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-13T02:22:41+00:00Added an answer on June 13, 2026 at 2:22 am

    NSUserDefaults is your best friend for persisting preferences state across application launches. Make sure you call the synchronize method after making a change to persist it to disk. In some instances, you may want to delay synchronizing until the app is about to be put in a background state.

    NSUserDefaults Class Reference

    Sample code:

    #define USER_DEFAULT_CASE_SENSITIVE @"USER_DEFAULT_CASE_SENSITIVE"
    
    -(IBAction)checkboxChange {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setBool:self.caseSensitive.on forKey:USER_DEFAULT_CASE_SENSITIVE];
        [defaults synchronize];
    }
    

    To restore it when the app launches again:

    - (void)viewDidLoad {
        [super viewDidLoad];
        // other code
    
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        self.caseSensitive.on = [defaults boolForKey:USER_DEFAULT_CASE_SENSITIVE]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a simple question, I'm still pretty new to this, but
Im still pretty new so bear with me on this one, my question(s) are
Question ONE: I'm still pretty new to .net, but have used Visual Studio for
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
I'm still pretty new to Objective-C coding (as evidenced by this question) and I
I'm still pretty new to this, but I'm trying to make a calculator for
I'm still pretty new to Cocoa/Objective-C, so I hope I can explain my question.
I'm still pretty new to doing this, so I'm not entirely sure it's possible.
I am still pretty new to using jQuery to do anything, but I have
Im still pretty new to NHibernate.Search so please bear with me if this is

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.