diff --git a/AVRsack/ASApplication.swift b/AVRsack/ASApplication.swift index 28d8aa5..46fa2f6 100644 --- a/AVRsack/ASApplication.swift +++ b/AVRsack/ASApplication.swift @@ -56,13 +56,13 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate { func applicationDidFinishLaunching(aNotification: NSNotification) { themeMenu.removeAllItems() for (index, theme) in enumerate(ACEThemeNames.humanThemeNames() as! [String]) { - let menuItem = themeMenu.addItemWithTitle(theme, action: "changeTheme:", keyEquivalent: "") - menuItem!.tag = index + let menuItem = themeMenu.addItemWithTitle(theme, action: "changeTheme:", keyEquivalent: "")! + menuItem.tag = index } keyboardMenu.removeAllItems() for (index, theme) in enumerate(ACEKeyboardHandlerNames.humanKeyboardHandlerNames() as! [String]) { - let menuItem = keyboardMenu.addItemWithTitle(theme, action: "changeKeyboardHandler:", keyEquivalent: "") - menuItem!.tag = index + let menuItem = keyboardMenu.addItemWithTitle(theme, action: "changeKeyboardHandler:", keyEquivalent: "")! + menuItem.tag = index } } func applicationShouldOpenUntitledFile(sender: NSApplication) -> Bool { @@ -142,15 +142,17 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate { } @IBAction func openSketch(item: NSMenuItem) { - let url = NSURL(fileURLWithPath: sketches[item.tag])! - let doc = NSDocumentController.sharedDocumentController() as! NSDocumentController - doc.openDocumentWithContentsOfURL(url, display: true) { (doc, alreadyOpen, error) -> Void in + if let url = NSURL(fileURLWithPath: sketches[item.tag]) { + let doc = NSDocumentController.sharedDocumentController() as! NSDocumentController + doc.openDocumentWithContentsOfURL(url, display: true) { (doc, alreadyOpen, error) -> Void in + } } } @IBAction func openExample(item: NSMenuItem) { - let url = NSURL(fileURLWithPath: examples[item.tag])! - openTemplate(url.URLByDeletingLastPathComponent!) + if let url = NSURL(fileURLWithPath: examples[item.tag]) { + openTemplate(url.URLByDeletingLastPathComponent!) + } } @IBAction func createSketch(AnyObject) { diff --git a/AVRsack/ASBuilder.swift b/AVRsack/ASBuilder.swift index 526a0f1..8b1aa70 100644 --- a/AVRsack/ASBuilder.swift +++ b/AVRsack/ASBuilder.swift @@ -56,6 +56,10 @@ class ASBuilder { let fileManager = NSFileManager.defaultManager() let libPath = (ASLibraries.instance().directories as NSArray).componentsJoinedByString(":") var args = [String]() + if ASHardware.instance().boards[board] == nil { + NSLog("Unable to find board %s\n", board); + return + } let boardProp = ASHardware.instance().boards[board]! let library = boardProp["library"]! var corePath = library+"/cores/"+boardProp["build.core"]! @@ -82,8 +86,8 @@ class ASBuilder { args.append("core="+boardProp["build.core"]!) args.append("libs="+libPath) args.append("core_path="+corePath) - if variantPath != nil { - args.append("variant_path="+variantPath!) + if let varPath = variantPath { + args.append("variant_path="+varPath) } args.append("usb_vid="+(boardProp["build.vid"] ?? "null")); args.append("usb_pid="+(boardProp["build.pid"] ?? "null")); @@ -125,7 +129,11 @@ class ASBuilder { task!.standardOutput = logOut task!.standardError = logOut } - + if ASHardware.instance().boards[board] == nil { + NSLog("Unable to find board %s\n", board); + return + } + let libPath = (ASLibraries.instance().directories as NSArray).componentsJoinedByString(":") let boardProp = ASHardware.instance().boards[board]! let progProp = ASHardware.instance().programmers[programmer] diff --git a/AVRsack/ASFileTree.swift b/AVRsack/ASFileTree.swift index 49f612f..c124ddb 100644 --- a/AVRsack/ASFileTree.swift +++ b/AVRsack/ASFileTree.swift @@ -252,7 +252,7 @@ class ASFileTree : NSObject, NSOutlineViewDataSource { func addFileURL(url: NSURL, omitUnknown: Bool = true) { let type = ASFileType.guessForURL(url) if !omitUnknown || type != .Unknown { - root.children.append(ASFileItem(url: url.standardizedURL!, type: type)) + root.children.append(ASFileItem(url: url.URLByStandardizingPath!, type: type)) } } func setProjectURL(url: NSURL) { diff --git a/AVRsack/ASProjDoc.swift b/AVRsack/ASProjDoc.swift index 64967f3..911c0a4 100644 --- a/AVRsack/ASProjDoc.swift +++ b/AVRsack/ASProjDoc.swift @@ -222,7 +222,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa func updateLog(AnyObject?) { if let logNode = mainEditor as? ASLogNode { - let url = fileURL!.URLByDeletingLastPathComponent?.URLByAppendingPathComponent(logNode.path) + let url = fileURL?.URLByDeletingLastPathComponent?.URLByAppendingPathComponent(logNode.path) if url == nil { return }