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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:08:44+00:00 2026-05-25T18:08:44+00:00

My application contains an NSTabView with two tabs. Further, the application itself has a

  • 0

My application contains an NSTabView with two tabs. Further, the application itself has a playState which is an enum. The playState is kept in a Singleton.

typedef enum {
    kMyAppPlayStatePlaying,
    kMyAppPlayStatePaused
} MyAppPlayState;

The playState gets synthesized here.

@property (readwrite) MyAppPlayState playState;

I want to switch the NSTabView every time the playState changes. Therefore, I prepared an IBOutlet to add a binding similar to this one.

[self.playPauseTabView bind:@"selectedItemIdentifier" toObject:[MyAppState sharedState] withKeyPath:@"playState" options:nil];

I already recognized the identifier must be NSString. This does not match with my enum which is an int. I could maybe use an NSValueTransformer to fix this.
Further, selectedItemIdentifier does not exists. NSTabView only offers selectedTabViewItem which then allows to access identifier or label. Though, I cannot find a way to switch the item itself based on the identifer.

  • 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-25T18:08:45+00:00Added an answer on May 25, 2026 at 6:08 pm

    In situations like that, I find myself doing one of two things:

    1) Register self (or some other object) as an observer of the property in question, and set the selected tab accordingly in -observeValueForKeyPath:ofObject:change:context:. It could look like this:

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
    { 
        if ( context == PlayStateChange )
        {
            if ( [[change objectForKey: NSKeyValueChangeKindKey] integerValue] == NSKeyValueChangeSetting )
            {
                NSNumber *oldValue = [change objectForKey: NSKeyValueChangeOldKey];
                NSNumber *newValue = [change objectForKey: NSKeyValueChangeNewKey];
    
                NSInteger oldInteger = [oldValue integerValue];
                NSInteger newInteger = [newValue integerValue];
    
                NSLog(@"Old play state: %ld, new play state: %ld", (long)oldInteger, (long)newInteger);
    
                // Do something useful with the integers here
            }
    
            return;
        }
    }
    

    2) declare a readonly NSString * property and declare that its value is affected by your playState property. Something like this:

    @property (readonly) NSString *playStateStr;
    
    // Accessor
    -(NSString *)playStateStr
    {
        return playState == kMyAppPlayStatePlaying ? @"playing" : "paused";
    }
    
    +(NSSet *)keyPathsForValuesAffectingPlayStateStr
    {
        return [NSSet setWithObject: @"playState"];
    }
    

    Now you have an NSString-typed property that you can bind your tab view’s selection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm on Delphi 2009, and my application contains a data module, which has a
I have a desktop application which contains an App.config (program.exe.config at release) with clearly
Suppose I have a simple to-do list application. The application contains two models: lists
My application contains many Dialog windows. It has gotten to the point that the
My web application contains a text box for which I would like to restrict
My application contains a bug, which makes script run infinitelly long. When I force
I've made an Android application which contains most used German words and sentences. The
I have a very simple scenario: My iPhone application contains a UIViewController implementation which
I'm creating a Flex 4 application which contains different modules in it. The main
My application contains a line graph which can display 20 or more datasets at

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.