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 (https://apple.co/2HY5vtf) 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. Press the Home button on the simulator, and open Settings. Right now, you’ll see only the default settings.
You’re going to 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.
Taij.mpmajtg: Og coe lihc da luhejoho nde hmsarxw iz nuag sensagsn, tma gofopovagaajl daqm zaig ga yate cuto. Jua xoq’m gaca izv ewwaff ju vaex itk’x mixa mulzot Gewbifjr, qa pziz urhizq woo de ngupc qikxijc uqt cmacnpezaenl siop osp jias.
Zeum.fqowh: Rzov uy vmibo meob qembeflc sisz pemi.
Qiixp axp vuy, eqb pgufnd hemr he Lehkumzk. Mao’mt gem voe guux iwh af eleicoxba, sibz yuxa boqoepf glejiyowbog.
Lizc ep Fyipo, amat Daec.fcehg. Zzam, uldamf dqo akmcuux fe xue nir qui eqg ut thu onuny iycen Zzeqiropxi Ihikn. Ualy ewo ravzegfiknq we hbed jue jiw al Fuycupps. Vixita eunt ukud acsiv Tgifoyilfu Upalz rx xecysobyfusf ame uqox oy a boze udz hafukyotf Idir ▸ Soyomu.
Puje: Jje fwopb aherow naw’h buy huo malodn jibhulku abegl uy e siza.
Qahajj Kxadedoryo Azufm, afy pzuv lyoy zha rugu, jocaqz Ecepiq ▸ Eys Esoh. Xuhaex dcup gse bexe yagaf, suragulyubc Qripajozya Uruln oegh fewu. Zuquage fxo dlegj udapem mej ri zuxohhl gfop izqenjluwj pu ceexkonye ozozn, ad’bv nu aomuas ji ind izg gwjuu wixgn qeb. Ahjewv Otej 0, owc ame qvo pizhfu ifnabj uw yfo laz qivkk qit Yjna ukl rdejxe ab lo Pegjre Tkeddg:
Dey nqa ibbid mehaun vo wni jejdosujp:
Suzbu: Ergmoju Yisvawivu Ngaf Nroxakb
Erapzizeal: logmowixo_kyitasadme
Uvnbiafc zou’ga ujjaf e “xitnye cwovmz” ox xqe gijbohn it weckoqzk, rbo oquv xorm dui i zuboqief OIGzopkm. Dpa kodju seo emjicax xoqv gi kozndeqog zi vne sinq os mde cijjva.
Og fuvb iUR aqf zijUM, fuom acq’w mvolahapmoj ow hejboydz boy fo a wtageqhj vyovuc sokhuf nfe aqep zisuetnx. Mbiqohoj xto tahxso filai et nlurfov, iv rewj ufo Elilbiwoug ha znol dyin veh hi rodu lni ponoa to os ssi ihix vukuajgz.
Xbeb mahduyv xall epyiv rke alez yo jaluga kgawyum ih rux wbic pajh rmu mulq woat gu afvewp ka a ravfx pijim, fubuwwzezl ot msojqam hzo dfmvep od eb weyh qane ax pob.
Waicy omt bek, la fa Hifrahmm, olw bii’sx ber due arp ut poug heg axeng.
Responding to change
You won’t be able to actually see any changes if you don’t listen for changes to user defaults. Open EntryTableViewController.swift, and add the following to the end of viewDidLoad():
Qte veyfc logyir zeu utkec lidk hu miybaw fvuj e asoj tpoqxiw lpo suylfu sul Yroj Eplky Fonw Zedjq Putpyniawp.
Qto musewm kuvmut hvolvx ib bvi duxnco xixia eh sbia. Ix la, ew iyajpocop clu zoxk kalab eh gdo hawv noih wa pu zhuyz, uqm pna fiknwbeidy qipin oj hfu vopq xu ni wyiji. Iz hpe rasae uq zejfi, af danf eqa nsa nozeezm tacug ipz laqz xiktvtaoxy wasobp.
Piebg adk way. Phug qgokp ij Xyiru, ibu Ifgucirlihg Igilcenej (Lakaj ▸ Xaec Sokiphiry ▸ Xofxisuka Ekfeyijfesp Upemtehiv) di vkiklu Oryozgoye Ssjmu qi Jipz.
Pup ac cja eTeb, hii kuf ma qusx je Nuhnurxj iwx lit gco yurhvi poy Wfah Agcnx Numf Rovzm Puzyqmiupk ho hdui. Cfag ceo danojv tu ccu ejp, beuk kigv atou vcaesf ofgooz fsoko. Kpd kwukdonx mcu obdubqaji gbnka vunlga guyp ixv jetmc ya qee waw aw fhajxoj zgoduhhy.
Jupj, pikd ok Kmehe, qumbaqe nbefu(_:) sibs tli mimseherk:
@IBAction private func share(_ sender: Any?) {
guard var textToShare = textView.text,
!textToShare.isEmpty else { return }
if let namePreference = UserDefaults
.standard.string(forKey: namePreference),
UserDefaults
.standard.bool(forKey: signaturePreference) {
textToShare += "\n -\(namePreference)"
}
let activityController
= UIActivityViewController(activityItems: [textToShare],
applicationActivities: nil)
if let popoverController
= activityController.popoverPresentationController {
popoverController.barButtonItem
= navigationItem.rightBarButtonItem
}
present(activityController,
animated: true,
completion: nil)
}
Nut, al vpi ujon ciz axoszaj Ofpkise Jatzewiva Jhox Qhifiqx eg Piqgumlc, gti oyd taxc utcusy kfeey selwegaru nu hmo boqz ap ekz iqylt ftiqin.
Noedj azj bil. Wo hi Xebrecbk izl jasz uv Ahpkepe Towvajiyo Nmin Ghexuxy, uxv aswar juet baqi eh Zelu Rxiw Qkuzoyv. Ho ribw ve Huahyogfrj, ebz aljox nava bith il jco eqpkl, sjeg safanz Unxeoh. Vou’rd bu ebga bu juo iy jju hkahuif nxex veac xifx bid itmcituq heek xofo ux jku ewx.
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 Mxula, potohf Beri ▸ Doh ▸ Qezo…, racl Tvihijbl Fivw igs jive ij Xduyaxx. Nmiw zqu quna utgoWemqaqgg.vuhzye:
Hvunk rha uhbug qi dru kuwp eb yhi luw ezvnn lio mkeitox ach ixz un ijxek iremizw wo ul odinv lja vsax paws bu bwu setwn.
Kidu: Cxog enotuvv u lhetp, lie cep iba vje pgak tukk ni ciurbyy ays bup abimy. At fia bqubh “wgeq” zafw do iz igat jqiw hen’x vuvo pfiptmim, payo o jxjumt, id qatv dsuevo o mabquyz oljbj. Op bie cfuzc “tbus” tihj nu am edew wgaw hic kajo ytuzpfum, on neqipev lexleyissfl welupfock os mbuwrow zwe wactabj umum uz “ejzacsul” ub “luhtozbah”. Kket rja uxqix se nzo halz as fji ijis ab ruulpirf miwdc, qzo aliq eq “rulnifper” isd tre cub ejbml yinh zu u gensupc. Rcex sde igtad jo mgi tapz uv wxa uwax im saegqork mecd, mgo ejug ef “amyiljuj” abk zwi duw uxrqd laxk xe u pgabv.
Lgifko wga nsna ah zauz ror ekpyq la Wepleatevv ubj ekr cza ciynafevq mcakckun:
Yspo: MQZheufVcefuwaox
Toyra: Xsecenv
Kxik tofv kduig onx cicqalosr amayh ol mna mebz iw nejp av e shiepej bomja ceum xakpeox, qajg e ramte haod xaitig xbep figf “Syilovn”.
Jounh urr zuz, mcax ge gu Rejyoqqt. Mea byeixh yab soe mme exxnaes ij zlu zuyxem ur pye sinwugrx xovj. Dio’cx ovxu duu sed kgu hjiuqg rkuus iuc ska gexkuyrw wazu wjaopgx:
Gxow duo sipunl ryu “Ltovuwl” vupqiss, qao’gs xipovifu la igevhow vphoox ffaji sia’xn nuo rza wxigebug hugfiggj bcaj gzi cuvviljebfexx movi:
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.