change NSTabViewItem from other NSView

Discussion in 'Mac Programming' started by kikko088, Jul 28, 2011.

  1. kikko088 macrumors member

    Joined:
    Oct 13, 2010
    Location:
    Italy
    #1
    I have a little problem, I want to change the view of my NSTabView from a Tab View...If I create an action with

    Code:
    selectNextTabViewItem
    on the window controller (where I define the nstabview outlet) all work perfectly...if I do something like this

    Code:
    AppController *controller = [[AppController alloc] init];
    [controller.tabView selectNextTabViewItem:nil];
    also if I do

    Code:
    - (void) next
    {
        [self.tabView selectNextTabViewItem:nil]; 
    }
        AppController *controller = [[AppController alloc] init];
        [controller next];
    where is the error?
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    Are you sure you want to be creating a new AppController object? I would think you'd be wanting to access an exiting AppController object.
     
  3. kikko088 thread starter macrumors member

    Joined:
    Oct 13, 2010
    Location:
    Italy
    #3
    In theory yes (I'm a beginner :( ), I have my AppController where I define a TabView Outlet, inside this TabView I have an NSView, If I want to change the tab from the NSView I have to create a new Object of AppController use a method of AppController for change the tab.
    Is wrong?


    kikko088
     
  4. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    If you create a new AppController, its TabView outlet won't be set. What is AppController and how it is rigged up? For example, is it your app delegate or is it an object you've added to a .xib file?
     
  5. kikko088 thread starter macrumors member

    Joined:
    Oct 13, 2010
    Location:
    Italy
  6. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #6
    And where is the selectNextTabViewItem action? You'll need to connect the AppController object in the xib to somewhere accessible by selectNextTabViewItem.
     
  7. kikko088 thread starter macrumors member

    Joined:
    Oct 13, 2010
    Location:
    Italy
    #7
    I create a new project from a clean app, so you can see where is the error :)
     

    Attached Files:

  8. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #8
    Don't create a new MyDocument in PrimaVista's change: method. Instead add an outlet to MyDocument in PrimaVista. Connect the outlet to the File's Owner in MyDocument.xib.
     
  9. kikko088 thread starter macrumors member

    Joined:
    Oct 13, 2010
    Location:
    Italy
    #9
    mmm I understand but isn't the good way for what I have to do (I think :D)...I want to do a route, in the first tab I set a variable, in the second tab I set anorther var, in the third tab I summarize all varibale.
    Then I need that the action of nextTab is on class controller (PrimaVista).


    thank you for your help!
     

Share This Page