I am trying swapping two Views in a Windows. I am using Cocoa Framework (just for Mac) with Xcode 5.1.1 and NSViewController for get it. All compile perfectly but this doesn't works, I get the next message from compiler:
"libdyld.dylib 0x00007fff866995fd start + 1"
.h file
#import "Cocoa/Cocoa.h"
#import "PrimaryViewController.h" //My views
#import "SecondViewController.h"
@interface
AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSView *myCustomView;
@property (strong) IBOutlet NSViewController *myViewController;
-(IBAction)button1Clicked:(id)sender;
-(IBAction)button2Clicked:(id)sender;
@end
.m
#import "AppDelegate.h"
@implementation AppDelegate
//@synthesize myCustomView = _myCustomView;<br/>
//@synthesize myViewController = _myViewController;<br/>
-(IBAction)button1Clicked:(id)sender {
NSLog(@"Clicked on the first button");
[[_myViewController view ]removeFromSuperview];
_myViewController = [[PrimaryViewController alloc] initWithNibName:@"PrimaryViewController" bundle:nil];
[_myCustomView addSubview:[_myViewController view]];
[[_myViewController view] setFrame:[_myCustomView bounds]];
}
-(IBAction)button2Clicked:(id)sender {
NSLog(@"Clicked on the second button");
[[_myViewController view] removeFromSuperview];
_myViewController = [[SecondViewController alloc]initWithNibName:@"SecondaryViewController" bundle:nil];
[_myCustomView addSubview:[_myViewController view]];
[[_myViewController view]setFrame:[_myCustomView bounds]];
}
@end
Can you help me, please?