Mac App新建空项目


新建项目

1 打开Xcode,选择OSX-》Application.下一步,不勾选StoryBoard
2 选择MainMenu.xib,删除Window.
3 新建CoCoaClass,SubClass of选择NSWindowController,勾选Also create XIB for user interface. 命名为MainWindowController.
4 选中新创建的MainWindowController.xib,选择Window,再属性栏,选择show the Attributes inspector,取消勾选Visible At Lanuch.
5 打开MainWindowController.m 重载windowNibName: 方法。

-(NSString *)windowNibName{
    return @"MainWindowController";
}

6 打开AppDelegate.m,代码如下:

#import "AppDelegate.h"
#import "MainWindowController.h"
@interface AppDelegate ()

@property (strong)NSWindowController *mainWindowController;
@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    MainWindowController *mainWC = [[MainWindowController alloc] init];
    [mainWC showWindow:self];
    self.mainWindowController = mainWC;
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
}

@end
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值