A: 

Aaron Hillegass - Cocoa Programming for Mac OS X, Chapter 29. View Swapping

brown.2179
+1  A: 
[window AddSubView:view0]

Windows aren't views in Cocoa, and nothing responds to AddSubView: anyway. (Remember that selectors are case-sensitive.)

[window setContentView:view0]

That is valid, but you'd want to make sure that view0's frame has the same size as window's content rectangle.

but i still don't get the new view displayed.

One possibility is that you are not actually talking to a window. You probably either haven't hooked up your window outlet or haven't loaded the nib with that window in it yet or, if window isn't an outlet and the window doesn't exist in a nib, you haven't created it in code yet. Either way, your window variable is nil, so you are sending messages such as addSubview: to nil, which does nothing.

If you have proven with NSLog or the debugger that you do, in fact, have a window to send messages to, and you still have the problem, make sure you are ordering the window in. If the window is in a nib, you may want to turn on “Visible at Launch” (which actually means “Visible at Nib Load”); otherwise, order the window in yourself by sending it a makeKeyAndOrderFront: message.

Peter Hosey
A: 

We'll after some... hard researching i got things working the way i want

here's my code


- (IBAction)showFirstView:(id)sender{
    theDetailViewController = [DetailViewController new];
    [theDetailViewController initWithNibName:@"DetailView" bundle:nil];
    NSView *splitRightView = [[theSplitView subviews] objectAtIndex:1];
    NSView *aDetailView = [theDetailViewController view];
    [aDetailView setFrame:[splitRightView bounds]];
    [aDetailView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
    [splitRightView addSubview:aDetailView];
    NSLog(@"%@",(NSString *)splitRightView);
}

what i was doing wrong was creating a class as NSView instead of NSViewController and trying to load the view just like that but you need to create a NSViewController and set this as the File's Owner class of the custom view XIB and then set the outlet VIEW to point at your custom view.

Thanks ya'll 4 your help.

Mr_Nizzle