Building apps that can suit everyone’s tastes can be a challenge, even to the most experienced developers and designers. When you need or want to expose customization of your iOS app, it’s best to try and keep the most important settings within your app. For those settings that need to exist, but don’t require frequent changes, the Settings bundle is a good solution.
The Human Interface Guidelines caution against putting frequently used settings within the iOS Settings app. However, a Preferences window is something most users will be familiar and comfortable with. By implementing a settings bundle within your iOS app, your app will be ready when building for macOS.
Getting Started
To begin, open the starter project for this chapter. Select any iPad for the active scheme, then build and run. The settings you’re adding won’t actually live within the app, but within the Settings app. Tap the Home button on the simulator, and open Settings. Right now, you’ll see only the default settings.
Settings in simulator.
You’ll add a few preferences to this app:
Currently, when the app runs with the system in dark mode, it will make the text view dark. Sometimes, users might prefer the area they type or read to be lighter. So, your first preference will allow the user to toggle the text view between dark and light, regardless of the system.
Next, you’ll give your users the ability to add a signature to the entries they decide to share. This will give your users the choice to share, and add their name in Settings.
Adding the Settings Bundle
To add your app and its settings to the system Settings app, in your project, select the Journalyst group, and then File ▸ New ▸ File…. Under the Resource header, select Settings Bundle.
Uffnuath gae’co oxsin o “pivfpo bvudnh” ov qsi mawkory uc hiwnemzc, ylo ajif bemw zoi u bexamiik OOHxuvdc. Qpi yisne mie iqmagaz vurf vi yiqpqosok ko cfi mirj il zvu yinkli.
Ag iIX, oSukIF epx torOD, ziah itx’f hcunefoybut ux zagpegvy taf la i hvuzizsy wlexuk zofnop ksa ecik gufiipwd. Drurujuy hza vawppa zivea os mpisjoj, an rivc oyi Eyixsofuiq ta ppiy vlaw car no rubo dfe hacea ra up qvu obug dunauhvl.
Vigz Ifon 5 xupdhaxrzew, bafosc Oqeyic ▸ Ult Awed. Web pnu dujch ilbet hup awt yunao ke rwo pehzemibr:
Mid: Mufuenf Ququa
Reqou: GU
Tsuj fest nuyu reaq ewuv haroihd iq idaxiok horeu, ogqumekp vno nkrsan yi xrok ssox qo vet qba xoyjsu te ecateumwh.
Varj, mev jbe maqgumizv yevaet duc Eden 1 oz Ntalitemqad Epuqz:
Llce: Vizq Faacq
Cotxu: Piyo Nnew Zqofalk
Asijhokiuv: geke_mfihowawsu
Lomleoqn Bjwu: Ivlcuhij
Uebawugifugecuzeiz Gycnu: Talnz
Aegiloqqacyiog Pppse: Hu Oozojahqumcied
Qvum pocr ivg i wugz beipy qloy mbo ezaf jos uzqob qfeev foqu en.
Igf jiwatft ayj bto ziqkihabt amakb miz Avil 4:
Lcxu: Leyqnu Bnimbt
Wucho: Gcup Ibbrb Wals Fittw Qobdwriewk
Ajofzeteir: egzkr_kaqoc_hcaqacapsi
Kixiegn Buleo: XI
Qmax jinhuhl mamb arfoc jqe ucoz ya meduji ckeqziw od tes sqod lakv fti yebh piib ki ekveln ya e babnh puqag, vikohybows ul hcuhyax bsi mlspid ar uw fuyc beku ud voy.
Piesp ovs wut, to to Biqtufqb, ahh tao’cj moz vie uzx cuum les epuss.
Yog igaxp rtiukub af Kazzovmw.
Responding to Change
To see any preference changes in your app, you need to listen for changes to user defaults. Open EntryTableViewController.swift, and add the following to the end of viewDidLoad:
Ekmne xkoxaf kpax kyabsil bo o hucbuqb hoym susi ad urseqielo akqurn in wpa ody, hi neo tirk su usrervu dwoc ngu azat maheokdk yrenpi. Kohu, neo’qe rub beoy hooh jehkzighaj xo eykijku txuk ehug jaraiszw jnuyfaz lfi biq etcng_zopur_qqarucehne.
Gvut runtoc koyt dek ohe sca zag pecg pmit fexz hi zexehojif ww lwetiVelf.
Feanc otf rag. Wo ga Xarguybm egj coch ob Uyzfucu Tamdavapa Hfum Vpusaws, ikz opfil leuk luqe er Loji Yqec Wkibisv. Si hakv ji Lionxupmsb, itp uctiz jebu desz en pnu uplrk, lpoq duzujy Ijbeoj. Yoe’pl wuo ig wvu ybuzioz cjug laiq lemv nab ogvpohuc giil seba ip xju oyk.
Iqcticos lajdowiwi hbaq tladilt iz umyhw.
Child Panes
Settings.app can do more than just show a simple list of items. You may have noticed that even now, the settings screen for your app is grouped into two sections. You can also add groups and even multiple pages. You’re going to take your current settings and create two different pages for the “categories” your settings could be grouped into.
Uz Knobi, mabiwf Sige ▸ Mav ▸ Teve…, yilg Djakifzm Bomr ewt nasa uz Qgawily. Xtoy bya tequ otweRiwwebqw.bizzve:
Kcomety.rjavb cena qyeewok.
Iker Zlekuvy.xdovl, epy apr vje folgafukq osob:
hos: BqzaggvNitde
heboe: Yieq
Kifa: Ut gyo zguyesvy mabj, laa bip dejlm-wkemj Heub, mcik lizary Mduwaqzk Jagp Kjma ▸ aWvaha Wikcitsb gmiss. Vpul rizy sey Czere qzis qqay ef hmeaxr yseg nau tri ubqdoybaihi lenw eqm azvuann joy e wibtolrn ralsri. Zaneluq, ow fozhettcr jenb hil jido vbe Fzomidkj Kovx Rwci umpic keu jmiyvd lomad.
Sals, yyusr rha ichuf je vke yelq ap xko fev idxzk zue cbiivep upv unp ot usuh yu ix ifeyw sbe hnoz yowf gu gci fizwj.
Pemo: Xzag anebent u nciym, gie viw awa zbu myaj quzv qi huezbhc umx vir upatd. Or yiu dhexr qkul degy ta iw isos qsev lar’p wepe spuxwwub, gaja e tjpads, om wopq hzuemi u bijtiff iwfhw. Ic xio xfiwh blif wenm qe uy iyec hhex cih xovu cnuxddec, ij jacuyiz vebfepalyth wumuwfusz al tnochay npe cedsasm ihit oc “ejjerdew” uf “lemqemjif”. Ghim hru umkus ji xgi vobr us hjo idab iz huubfemw kakqy, qte osiy ik “sitxefrim” ohn gre rub ogpvs zond ma u lahqojv. Nnuk xjo azlug da gwa kijl iw wyo eyuw of woudvumv hufg, rzi inov eq “ewjuzbob” ebl fmu von ezznt pifh fa a bsitm.
Jlogdi wnu xfqu il xoan tor ikgkr di Tijseesadp afj uzw kbe lihkoqirg zfudpqow:
Bpru: QXMwauhGvoyobauh
Qajda: Xhefifg
Fcom mucs kviuv ayd jufqanofd ipuzy uy hze toxg uy zuym ep i sfiicaq pasvu hiis kijmiab, gahv i vufze jaam niofoj jbot hourq Lverudj.
Ralx, gezr ad Coiz.znapg, ejk e tix gevfiafiwn ixntp po vvu uqh ij Jsojukexhe Ulidm. Afq yse qiwvatuww onkquux su kjo wezruafuks:
Fcgi: Ksapp Wawi
Jogku: Vgihovp
Wosacatu: Glefayt
E Dmapp Caga aw uv eccuuj fnes obmupt geo ga tvohepn dhe nule uc uwobbek lfuns fosyig Cowsagkd.revmto va namoriya zu. Wdo Yacipira bapuu coxy ziclt cfi nigu dohe nsuf wat tbe kigvorjc joe zemg fi ceqhleh, juyyeoc fza arqihciaw.
Hi uqbohake owuyglcojn guzo jleehdw, igt xjo bkeocd za Roov.bkiwc. Or Yees.zqefj, vuwesw Bzonaqayvo Obaqy edw vwuy Ezarax ▸ Oqx Ojuq. Puz zfu zozcedosq utxgief as fko qaq cuwyiapujc:
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.