Upgrade to Pro — share decks privately, control downloads, hide ads and more …

忘れないで!mac app!! コマンド編

Akio Itaya
May 23, 2018
1.4k

忘れないで!mac app!! コマンド編

potatotips #51

Akio Itaya

May 23, 2018
Tweet

Transcript

  1. Import Cocoa Class ViewController: NSViewController { func create() { let

    dir = “\(NSHomeDirectory())/Desktop/swift” let task = NSTask() task.launchPath = “/bin/mkdir” task.arguments = [dir] task.launch() } } ઈରύε
  2. Import Cocoa Class ViewController: NSViewController { func create() { let

    dir = “\(NSHomeDirectory())/Desktop/swift” let task = NSTask() task.launchPath = “/bin/mkdir” task.arguments = [dir] task.launch() } }
  3. Import Cocoa Class ViewController: NSViewController { func copy() { let

    panel = NSOpenPanel() panel.canChooseFiles = true panel.canChooseDirectories = false panel.allowsMultipleSelection = false panel.allowedFileTypes = NSImage.imageTypes panel.begin(completionHandler: { num -> Void in if num == NSApplication.ModalResponse.OK, let path = panel.url?.path { Self.read(url: path) } }) } }
  4. Import Cocoa extension ViewController { func read(url: String) { let

    home = NSHomeDirectory() task.launchPath = "/bin/cp" task.arguments = [url, home + "/swift/sample"] task.launch() } }