Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
[App] New document Menu Item
Browse files Browse the repository at this point in the history
  • Loading branch information
endocrimes committed Feb 10, 2016
1 parent 0bfd295 commit 5d21151
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/CocoaPods/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15D9c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10089" systemVersion="15A284" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10089"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -86,6 +86,11 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="File" id="bib-Uj-vzu">
<items>
<menuItem title="New Podfile" keyEquivalent="n" id="Q1o-LS-sQI">
<connections>
<action selector="newDocument:" target="Qtz-kf-riq" id="oL2-Tr-Eyw"/>
</connections>
</menuItem>
<menuItem title="Open Podfile…" keyEquivalent="o" id="IAo-SY-fd9">
<connections>
<action selector="openDocument:" target="Qtz-kf-riq" id="uid-Xs-MhY"/>
Expand Down
12 changes: 12 additions & 0 deletions app/CocoaPods/CPDocumentController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ class CPDocumentController: NSDocumentController {
}
}

override func newDocument(sender: AnyObject?) {
let openPanel = NSOpenPanel()
openPanel.allowsMultipleSelection = false
openPanel.allowedFileTypes = ["xcodeproj"]

openPanel.beginWithCompletionHandler { buttonIndex in
guard buttonIndex == NSFileHandlingPanelOKButton else { return }
guard let fileURL = openPanel.URL else { return }
print(fileURL)
}
}

// `noteNewRecentDocument` ends up calling to this method so we can just override this one method

override func noteNewRecentDocumentURL(url: NSURL) {
Expand Down

0 comments on commit 5d21151

Please sign in to comment.