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

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

Eae7b6aeee72d3081b01d09a2d675f9a?s=47 Akio Itaya
May 23, 2018
1k

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

potatotips #51

Eae7b6aeee72d3081b01d09a2d675f9a?s=128

Akio Itaya

May 23, 2018
Tweet

Transcript

  1. AKKEY / AKIO ITAYA Cyberagent, Inc. ๨Εͳ͍Ͱʂmac appʂʂ ίϚϯυฤ◦

  2. ໊લɿ൘୩ ߊྑɹ/ɹ͖͋ͬʔʢAKKEYʣ ৬छɿiOS ׆ಈɿ@AkkeyLab Ұݴɿݸਓ։ൃͬΆ͍ਓؾΞϓϦൃݟͰ΍Δؾഒ૿ ࣗݾ঺հ

  3. ͲΜͳΞϓϦ࡞ͬͯΔਓʁ ※஫ҙɿݸਓ։ൃ

  4. ͔Θ͍͍ΞϓϦ

  5. ͔Θ͍͍ΞϓϦ • 1࣌ؒຖʹඒগঁͷ੠Ͱ࣌ؒΛ͓஌Βͤʂ • ௨஌όʔʹ͸ඒগঁΠϥετ͕ʂ • ৬৔Ͱ΋҆৺ͷϛϡʔτઃఆ౥ࡌʂ • ෆఆظͷ࢒ۀʹ͸ؾΛ͚ͭͯͶὑ

  6. ͔Θ͍͍ΞϓϦ • 1࣌ؒຖʹඒগঁͷ੠Ͱ࣌ؒΛ͓஌Βͤʂ • ௨஌όʔʹ͸ඒগঁΠϥετ͕ʂ • ৬৔Ͱ΋҆৺ͷϛϡʔτઃఆ౥ࡌʂ • ෆఆظͷ࢒ۀʹ͸ؾΛ͚ͭͯͶὑ

  7. ͔Θ͍͍ΞϓϦ • 1࣌ؒຖʹඒগঁͷ੠Ͱ࣌ؒΛ͓஌Βͤʂ • ௨஌όʔʹ͸ඒগঁΠϥετ͕ʂ • ৬৔Ͱ΋҆৺ͷϛϡʔτઃఆ౥ࡌʂ • ෆఆظͷ࢒ۀʹ͸ؾΛ͚ͭͯͶὑ ※৬৔Ͱͷ࢖༻͸ࣗݾ੹೚Ͱ͓ئ͍͠·͢ɻৗࣝͷൣғ಺Ͱʂ

  8. ͔Θ͍͍ΞϓϦ • 1࣌ؒຖʹඒগঁͷ੠Ͱ࣌ؒΛ͓஌Βͤʂ • ௨஌όʔʹ͸ඒগঁΠϥετ͕ʂ • ৬৔Ͱ΋҆৺ͷϛϡʔτઃఆ౥ࡌʂ • ෆఆظͷ࢒ۀʹ͸ؾΛ͚ͭͯͶὑ ※৬৔Ͱͷ࢖༻͸ࣗݾ੹೚Ͱ͓ئ͍͠·͢ɻৗࣝͷൣғ಺Ͱʂ

  9. ͔Θ͍͍ΞϓϦ ѪɹশɹɿɹϓϩੜͪΌΜ ೥ɹྸɹɿɹ17ࡀ ৬ɹۀɹɿɹJK ஀ੜ೔ɹɿɹ1݄11೔ ϘΠεɹɿɹ্ࡔ͢ΈΕ Ωϟϥɹɿɹixy ϓϩάϥϛϯάੜ์ૹ ༷ͱͷڠྗ

  10. ͱ͍͏͜ͱͰɺ

  11. mkdir command

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

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

    dir = “\(NSHomeDirectory())/Desktop/swift” let task = NSTask() task.launchPath = “/bin/mkdir” task.arguments = [dir] task.launch() } }
  14. • Sandbox ͷ༗ແͰऔಘͰ͖ΔσΟϨΫτϦ͕ҧ͏ ແɿ ~/ ༗ɿ ~/Library/Containers/com.app.name/Data/ ஫ҙ Bundle ID

  15. cp command

  16. ίϐʔݩΛબ୒

  17. 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) } }) } }
  18. Import Cocoa extension ViewController { func read(url: String) { let

    home = NSHomeDirectory() task.launchPath = "/bin/cp" task.arguments = [url, home + "/swift/sample"] task.launch() } }
  19. • Sandbox ར༻ͷ৔߹͸ઃఆมߋ͕ඞཁ ϑΝΠϧબ୒ɿ FileAccess > User Selected File ஫ҙ

    ྫɿRead Only
  20. ͥͻɺ༡ΜͰΈ͍ͯͩ͘͞ʂ

  21. GitHub / Qiita : @AkkeyLab

  22. Thank you !!