Audit force unwraps, removed a few

This commit is contained in:
Matthias Neeracher 2015-03-18 00:17:55 +01:00 committed by Matthias Neeracher
parent c9ad05a693
commit 5ea9dc38a8
4 changed files with 24 additions and 14 deletions

View File

@ -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,16 +142,18 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
}
@IBAction func openSketch(item: NSMenuItem) {
let url = NSURL(fileURLWithPath: sketches[item.tag])!
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])!
if let url = NSURL(fileURLWithPath: examples[item.tag]) {
openTemplate(url.URLByDeletingLastPathComponent!)
}
}
@IBAction func createSketch(AnyObject) {
ASApplication.newProjectLocation(nil,

View File

@ -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,6 +129,10 @@ 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]!

View File

@ -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) {

View File

@ -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
}