Skip to content

Commit

Permalink
Update to latest swift syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelhanneken committed Sep 24, 2016
1 parent f1d12d4 commit 9701071
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Icns Composer/DragDropImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ class DragDropImageView: NSImageView, NSDraggingSource {
}

// Track mouse down events and safe the to the poperty.
override func mouseDown(_ theEvent: NSEvent) {
override func mouseDown(with theEvent: NSEvent) {
self.mouseDownEvent = theEvent
}

// Track mouse dragged events to handle dragging sessions.
override func mouseDragged(_ theEvent: NSEvent) {
override func mouseDragged(with theEvent: NSEvent) {
// Calculate the drag distance...
let mouseDown = self.mouseDownEvent!.locationInWindow
let dragPoint = theEvent.locationInWindow
Expand Down
2 changes: 1 addition & 1 deletion Icns Composer/IconImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct IconImage {
/// - parameter url: The url where to save the image.
func writeToURL(_ url: URL) throws {
// Define the image name.
let imgURL = try url.appendingPathComponent(filename, isDirectory: false)
let imgURL = url.appendingPathComponent(filename, isDirectory: false)

// Get the png representation of the image and write it to the supplied url.
if let png = image?.PNGRepresentation() {
Expand Down
14 changes: 7 additions & 7 deletions Icns Composer/Iconset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import Cocoa


enum IconsetError: ErrorProtocol {
enum IconsetError: Error {
case missingURL
}

Expand Down Expand Up @@ -60,18 +60,18 @@ struct Iconset {
// Create the .icns file.
try runIconUtilWithInput(tmpURL, andOutputURL: url)
// Open the working directory.
NSWorkspace.shared().open(try url.deletingLastPathComponent())
NSWorkspace.shared().open(url.deletingLastPathComponent())
}

/// Create a new iconset within the user's temporary directory.
///
/// - returns: The URL where the iconset were written to.
private func writeToTemporaryDir() throws -> URL {
fileprivate func writeToTemporaryDir() throws -> URL {
// Create a randomly named dictionary.
let icnSet = "\(Int(arc4random_uniform(99999) + 10000)).iconset/"
let tmpURL = URL(fileURLWithPath: NSTemporaryDirectory() + icnSet, isDirectory: true)
// Create the temporary directory.
print(tmpURL.path!)
print(tmpURL.path)
try FileManager.default.createDirectory(at: tmpURL, withIntermediateDirectories: true, attributes: nil)
// Save every single associated image.
for image in images {
Expand All @@ -92,12 +92,12 @@ struct Iconset {
throw IconsetError.missingURL
}
if output.pathExtension != "icns" {
output = try output.appendingPathExtension("icns")
output = output.appendingPathExtension("icns")
}
let iconUtil = Task()
let iconUtil = Process()
// Configure and launch the Task.
iconUtil.launchPath = "/usr/bin/iconutil"
iconUtil.arguments = ["-c", "icns", "-o", output.path!, input.path!]
iconUtil.arguments = ["-c", "icns", "-o", output.path, input.path]
iconUtil.launch()
iconUtil.waitUntilExit()
// Delete the temporary iconset
Expand Down

0 comments on commit 9701071

Please sign in to comment.