diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index 95a12b8..797a241 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -133,17 +133,14 @@ class Document: NSDocument { } /* - Parses the chunk filename, ex. 1~1 to integer coordinates. + Parses the chunk filename, ex. "1~1.chunk" to integer coordinates (1, 2). */ func parseChunkFilename(_ filename: String) -> (Int, Int)? { let pathURL = URL(fileURLWithPath: filename) let pathComponents = pathURL.lastPathComponent.replacingOccurrences(of: ".chunk", with: "").components(separatedBy: "~") - let x = Int(pathComponents[0]) - let y = Int(pathComponents[1]) - - if x != nil && y != nil { - return (x!, y! + 1) + if let x = Int(pathComponents[0]), let y = Int(pathComponents[1]) { + return (x, y + 1) } else { return nil }