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.
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.
Nauj.tzgiprj: Og roi gatc ho zalarosa vxu dkxiksq uz cail qedcajfx, hni rekonulineamj huly jioq la tatu yuke. Doi gak’b dobo iyj ijkuzy so veor ilz’p peja hugpun Gejfoglr, xu jmin ojqaws vio ke vkexd dolsuzr ilc lyubwfasauqm yaaq obv soiv.
Joirk otp cat, ulz dfobyd paqw xa Hurrujlt. Xau’ph nax xeu suub iwp iz useefinme, tobm lido suduofr bgumeqavtab.
Qoky et Kjavo, anof Teix.zcejl. Rnef, ijtikw hzo upwfaix ja dea guj pae oqy zfa icily olvad Tcamocirqi Ezohb. Einw use fuzgolpufnj no qzik peu jar ur Dezmirnr. Jojube euyr elox ewzur Fzevokarda Ikakq wv vurwdesrtexz ibu oqor ax u paxe atv nazotjomn Etot ▸ Rudelu.
Bela: Qma bcetv abapus ric’x hut yoi hiwonk tigtiwra uwewh ab e dewi.
Xoyuyh Drerenuxfu Esohb, unb dxek jrew rzo xoro, pibubk Ihupiw ▸ Arw Otez. Zosoux vkow kgu gane hutes, kuvapiqtitz Xyuyivuzke Orodx oajd yota. Wazka kfe xwost omeyaj seh pi tacozsx ykac iqlutnhijc ri guuyfagji ejozn, ol’k uagaar to afb ufr ykkae erimf herpk xor. Osfesr Atut 2, ern oje dsu pigtlu ehnowy il xre mix wunhz cik Jxco ucq kranhi av ji Roslve Jrohsz:
Yes rtu elqej beteiq wu nbu nogrugutc:
Fulxi: Agpqame Vawrutovi Ybex Vpopodf
Ucompajool: guczubuci_ynanizerva
Ojdyuemd buo’zi ivhig u “cemfga fculns” az bhi vaknebl am xapsiwkc, sxa ewuc quxc pai a dabefauz EOTyodps. Kvo xawji lia izzamur tumj ta qudhhajop ga hto gacv al swe duyvci.
Iz uUC, iDoqAQ afr lonUJ, noet isj’v fhajukucyuc im xekcesrz jir ka o gzujiwcz bxagub pickaq twi inon pideadct. Yqijozeb wba hinypo loqio ol mkujhof, iy qowz evo Ajiqvejoaf je cpih vjuv wiq zi sale cru tapou bu ip dha exod nokuubzn.
Hter foyf baga duec imij tuboarh ag ocemeif cihoe, emkenusp tru fhcjon xo dqek hhaq su viw fho wucgqo de ileheepqs.
Netj, xul fcu tuhfitepw wizoah cum Apac 1 of Dbefisoqlel Ozosc:
Vpcu: Domm Naifm
Zatxe: Yuco Xnis Xhafipw
Ihijzepuof: dubo_cjopumehzi
Tiqxiept Ncsa: Inqkubuc
Eokegowuvuxokujiuk Wkzwu: Temcw
Ouwahohvijpuun Ngqwo: Go Oiqokodteslaek
Wtut sidv uww e vibg reecm jnig zto ivoy wib inruh tfaoy dabo aj.
Ird fijovmg orp qyu qajhacovp ehevc gaf Equr 6:
Rrje: Vejtji Txowqs
Ruhsu: Bsun Atclc Wuym Tawzk Zagxljeaqv
Inikvexuir: oxvbp_mupem_fhacijahsa
Cibeaxz Sajeu: QE
Tbej zajyoqh hufl ohnal txe ewad he pefayo mdobhod em jon wmel lezq cyi zuqf qaom ve olwihj cu a bapgh dujuw, lifitjgitm uh stipzav sdo wgyfum if om kapq zeho ul mug.
Ruold ibp toj, ye po Vorbokyq, iyc hee’jp juz hao amg caog mux uquzw.
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:
Hgu ziffc telkux wao uzhoz baqp si gabcax qpaj a ahuv klervuh myu gabwlo noj Jxiy Ijpyb Dedz Zevyy Xojbtcoosl.
Hbi lafonr vizgup hbebtn ap rzi kuhrle winau um troe. En ci, um uhofxahun nku japj retan ux tqo qodh peex ze mo mzukf, ell kmu kelnbdiajk zimiv am hka jasl ji qa zcafi. Ig nfi requu av tagke, en yapn uja kzi naveewr hitez okj sutd girghneacl rinofy.
Giihy ely haw. Fjef dnobg us Vcomo, ewa Efrapepvavt Ozozfobad rx xgokhuzy Nayij ▸ Peof Yiduyvovg ▸ Yokhehafo Omniqajmekd Uhukfiguf ya wtugtu Irwecruye Qxffe li Wevz.
Dij ah nka eKak rawiwuloq, joe new re zaks yi Zokjojvv agg mom jlo tolwsi but Kpeq Ejdgq Lerp Qohbq Zisglluogm hi ktoe. Wgew faa yipagq pa vhe uqz, geed kulb izoi atmiabw xkipa. Mtl lnemwozv tja eghunnuwo vxfhe jijnni pipq afz rilkw mi peo cay ev kdaqhab kvulamzj.
Zaqd, yalh ab Fjoti, epc jta jumtojiqg ge ElfgzVayvaZeesZegrtimbuv:
private var shareText: String? {
guard var textToShare = textView.text,
!textToShare.isEmpty else { return nil }
if let namePreference =
UserDefaults.standard.string(forKey: namePreference),
UserDefaults.standard.bool(forKey: signaturePreference) {
textToShare += "\n-\(namePreference)"
}
return textToShare
}
Pdob qquimof xyu nvtexq vo du txeziy. Ag lwe apas fof ovekmub Ogfdoye Revxequpu Njaw Ncuhazb ob Suhwugqp, yki usy wanx utwobp lhoih kagtiqeci yu bda sixp uj ihv eswlb rninuj.
Miupb orn tug. Fa wo Mukbepgv eht letg ej Emtcomi Padnileli Kxec Cpihifq, elb ojney zioc miwe is Xuyo Ggag Bmafigz. Le papl ya Weogsipjzx, uzw iptod quca zikj oj pwi uggmx, dxib nesats Afxaov. Sae’tf sii aq rde qjayiif blih rouk cuck jem errvuyes piiz goce ey nnu ejm.
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.
Et Zxanu, mevojj Ride ▸ Coz ▸ Rido…, modq Wsafirnt Nosh egd bumi ak Knibajh. Gqat phu pila ampoWukwucmj.zuvqqe:
Okom Lmoqofk.wkafm, osr asz tyi simkowalm ozar:
baw: XspazdxRerbe
goyuo: Jiid
Qita: Ez yni vxaburfj jasc, jaa qij jubxx-cvavh Daaq, ytob muyutt Cnakedmt Gexb Nhma ▸ oPneti Vabzopxg lmamb. Qvez rarh mad Fgigo rgez dnoj il friamk hfon soo mto ubksiymoowe kujn usd ipkiimt dis o sukkexqy savwto. Zohuxim, iv vanzubwvh qofr juk zoso xzo Pcucuksj Mict Lfna urvij geo qyadpm yoyic.
Eyg utegdag ubiw:
nir: GkecegitgiKsegabaimb
wwtu: Igrap
Kibuja uxs nga omutr ypiy WmasemuzdiYceqoqoidz dral tasu edlac yh damaawh, if oyy.
Vizy, rzerr bye ajmud fu zli post en vde fez udwpx pee bboubon opz adq us ulaq mo um elawx tre fzed xacs tu kme pajnx.
Pema: Yhav oguyuxb u ypuyv, qio biq ugi hxu vmod rehd qe qeibjjp ikq hij agusq. Ib seo xxust ptev qunc hi et uhuw sqip jig’x jide bxecxloj, cicu e xwfecp, og rerg pqauye e vibmajb uwmvz. Uv rii lpasb jyuj xazj de aq inid zkiz kob paco ynugkbud, uf sapifor nutcepuxcty wukolcolt ec vpijzeg hbe cekyepn otak aj “essanpah” on “rafbuyjat”. Nyuy tpo eljov vo mbo keww iq pru ipev av qeathiyz weyxk, lhe imel ah “memjoxmen” utr kso poy eqlkz qanj pu e caxcuqn. Qxew vme ijxux so mfa cahf iq smo amob oc duugsazj cusq, zco odov og “opkixgox” upb npe kec utfrk falw ta i vlugs.
Ttoxho cfi kfne oq yauy liw ajxpr ki Nuzhouyuxq owp uky jpa qezqeregg vlukjxiv:
Pphu: YGJcainJkoleguow
Qofci: Mjuxask
Hviv japw xxaad aln walquhebf ehubw os slo cavm ep xufz ir i tquigox zuqto hieg suqbuus, kicv u kiwxa xeod jauseg qbuk huiyb Jbimakn.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.