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

環境設定の作法 / Manners of Preferences Window on macOS

1024jp
December 22, 2018

環境設定の作法 / Manners of Preferences Window on macOS

macOS native symposium (http://macos-native.github.io) #02 登壇資料

macOSアプリケーションにおけるお行儀の良い環境設定の作り方、またUserDefaultsの取り回しについてをライブコーディングを交えてお見せします。

1024jp

December 22, 2018
Tweet

More Decks by 1024jp

Other Decks in Technology

Transcript

  1. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ࣗݾ঺հ CotEditor Gapplin BathyScaphe

    Qli application work plain-text editor SVG viewer 5ch browser movie player 2014年に
 正式引き継ぎ サポーtメンバー
 (主にデザイン・UI) 新作
  2. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ͷྺ࢙ cite: Mac OS

    X 10.0 Cheetah, 512 Pixels, on 2018-12
 https://512pixels.net/projects/aqua-screenshot-library/mac-os-x-10-0-cheetah/ Mac OS X 10.0 | Mail.app
  3. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ͷྺ࢙ cite: Playing around

    with Mac OS X Puma –YouTube, on 2018-12
 https://www.youtube.com/watch?v=2SBI27xUnug Mac OS X 10.1 | System Preferences © 2018 1024jp
  4. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT A preferences window

    is a modeless dialog that’s used to adjust an app’s preferences. Typically, a preferences window contains a toolbar that includes buttons for switching between groups of related settings, which are displayed in a view beneath the toolbar. These groupings are known as preference panes. cite: “Preferences Windows”, macOS Human Interface Guidelines, on 2018-12 ؀ڥઃఆ΢Πϯυ΢͸ΞϓϦέʔγϣϯͷ؀ڥΛௐ੔͢ΔϞʔυϨεͷμΠΞϩά Ͱ͋ΔɻҰൠతʹ؀ڥઃఆ΢Πϯυ΢͸ɺؔ܎͢ΔઃఆͷάϧʔϓΛ੾Γସ͑ΔϘ λϯΛ಺แͨ͠πʔϧόʔΛ͍࣋ͬͯΔɻ͜ΕΒάϧʔϓ͸؀ڥઃఆϖΠϯͱͯ͠ ஌ΒΕΔɻ Preferences Windows
  5. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT cite: “Preferences Windows”,

    macOS Human Interface Guidelines, on 2018-12 Preferences Windows – Apply preference changes immediately. – Disable the Minimize and Zoom buttons. – Make sure the toolbar is always visible and noncustomizable. – Indicate the active toolbar button. – Update the window's title to reflect the currently visible preference pane. – Restore the last viewed preference pane. ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ
  6. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ? ؀ڥઃఆ΢Πϯυ΢ͷجຊͷৼΔ෣͍ ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ

    ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ ӈԼʹϔϧϓϘλϯΛ෇͚Δɻ ϖΠϯഎܠ͸σϑΥϧτ৭ɻ σεΫτοϓʹରͯ͠ηϯλϦϯάͯ͠දࣔ͢Δɻ EscΩʔͰ΢Πϯυ΢Λด͡Δɻ esc
  7. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ϖΠϯ੾Γସ͑ͷྲྀΕ General Advanced πʔϧόʔΞΠίϯΛΫϦοΫ

    ϖΠϯඇදࣔ ΢Πϯυ΢มܗ ϖΠϯදࣔ ΢Πϯυ΢λΠτϧมߋ ① ② ③ ΫϦοΫͨ͠ΞΠίϯΛબ୒ General Advanced
  8. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp – ͜Μͳʹڧ͍ఆܕ͕͋ΔͷʹɺͦͷৼΔ෣͍Λఏڙ͢Δ Cocoa API ͸ ɹ

    ɹɻ – ͱ͜ΖͰɿmacOS ։ൃऀ͸ Interface Builder ͕޷͖ɻ – ؀ڥઃఆ΢Πϯυ΢͸Ұ൪ Interface Builder ͕׆͖Δ✨ͱ͜Ζɻ ؀ڥઃఆ΢Πϯυ΢Λ࡞Δ Modern ✔ Storyboard ✔ NSTabViewController Legacy ✔ Xib ✔ NSWindowController →みんな独自に実装しているのだ(マジかよ... ੲ͔Β ͳ͍ ͩͬͯ Cocoa Binding ͸
 ɹɹɹɹɹ ɹɹ࠷ߴͩ΋ͷɻ
  9. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp $PDPB όΠϯσΟϯά ͩͬͯ Cocoa Binding ͸
 ɹɹɹɹɹ

    ɹɹ࠷ߴͩ΋ͷɻ – Key-Value Observation Λར༻ͨ͠ View ͱ Model-Controller ૚ͷಉظػೳɻ – macOS ʹ͔͠ͳ͍ɻ – Interface Builder ͔Βར༻Մೳ Moof! Input Field UserDefaults Text Field bind bind Moof! NSObjectベースである必要がある Mac OS X 10.3 Panther から存在 → 冗長なグルーコードが不要に。 .value [“message”] .value Model View View
  10. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp 4UPSZCPBSE ࣮૷ͷ᠘ ⚠ NSTabViewItem.label ͕ϩʔΧϥΠζ͞Εͳ͍ɻ࠷ѱͩɻ ⚠

    tabView(tabView:willSelect:) ͰͷεΠον͸ macOS 10.12↓ Ͱࢮ͵ɻ – “endAppearanceTransition called too many times” ͩͦ͏Ͱ͢ɻ – macOS 10.13 Ҏ্͔͠૬खʹ͠ͳ͍ͳΒؾʹ͠ͳͯ͘Α͍ɻ – tabView(tabView:willSelect:)  Ͱ͸  tabViewItem.frame  Λर͏͚ͩʹͯ͠ tabView(tabView:didSelect:) ͰεΠον͠Α͏ɻ → viewDidLoad() あたりで手動でローカライズしよう。 → macOS 10.12を切ろう。
  11. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ·ͱΊ – ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ –

    ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ – ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ – ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ – ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ – ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ ʴ – ӈԼʹϔϧϓϘλϯΛ෇͚Δɻ – ϖΠϯഎܠ͸σϑΥϧτ৭ɻ – σεΫτοϓʹରͯ͠ηϯλϦϯάͯ͠දࣔ͢Δɻ – EscΩʔͰ΢Πϯυ΢Λด͡Δɻ by ౒ྗ໨ඪ by HIG  Cocoa Binding ͸࠷ߴɻ