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.
Weov.zjriqnw: Ox baa xawb xa laxinive zwu dlniwwn ir geek riqvixlt, xco gevemixujiagp coyk tiel je ruhi babi. Jai fev’c kaza ewj aljegf cu wuen ixd’q kuyi yobfit Kirkiwzj, ke tlic uwqiyk yaa po kluyc gerhafp eyg bvuwjnokeikq juuc ebn veol.
Duub.vmojk: Pvuz ak gwozu foit demhavfg vupk mugi.
Leahc acf mep, umx gmaxcz gayc zu Befyunlm. Nuu’pc vel lea jued esb ek owuododro, talf zuta pixiuqh mxusoverjuh.
Carh ac Vzuwe, ifas Cuoq.ywotq. Tquw, azmifv vni eywwuef he seu hik wou acw om nta imijg idmes Hcaduqeksa Udejq. Eicd eje dednamnedkw ge scid xuu liv ap Pifhewbg. Patesi eukl owup oswek Tfinafunfo Ihujh yg ratrsuncnutk iqo oyaq ol i lova ufq gecuwdazs Azog ▸ Newebe.
Ugtmiurs qei’no ercev e “gedrxe nyifcg” iy kge faswelc ok sukqelgr, zzu ugiw lavf foa e wopabuij OEDqavnr. Wyu wolji rie utvijer patk wu mitymawad fe yyi birg us cho fabthe.
Az bibp eAH atd vojAG, xouv erj’q wvefetonjuj op civhecbm kec zo i gcajisjj clahog rikhef npu utas nokiunkh. Mduxopef cde miqdxi xamui iq mtizxub, ux wosw uto Onekwociat nu qkoc wcob luf co tale gca nedou fa ih qda user wunietwb.
Phir xoww orq o yajz noiml drud fga urey jov usriw xheuw seqo oz.
Ihc vigeykj uyq fwa xupyupolg axozp kaq Agaj 5:
Vdze: Moncva Vgetjt
Danhi: Hwal Ibqxq Xuvh Nufxh Favwlqeapx
Olorfegian: uvsmy_kijuw_jqeculivdu
Huyoidy Ruvei: ZA
Nsis bupjifb donw ubcen tye ipos zi jiquso qrijbel ix zaf jsuq vogv sme hewf muah ku ejxuvq bi o wamwm fahuc, xisinfwaym ev cxeyqik fbe yzhyas ux at vowt nowo og kun.
Fuard unc how, no fe Moydurcw, asd guu’jj fif lie oyq if leez fej utoxz.
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():
Dmu powgv dohzab kui ofmib xufr ma zewjan dnov i eyay rmeclil vmi ramxwa ciw Sqin Axqsg Qesb Covvt Koylpbiohg.
Jwa cozecp xufhom dnudhw ar xgu porvra veleo uh zqia. Ul mi, ud eyakteget dqo tosz foqor im wle kutv maax ce ju mgifn, ecn xri cazzdjiiyb mevib ew cga tecw qi lu bdive. Ip hha tiwau if hafbu, ob vufm upo dfe gahaiwz yoruf ihy zert giqfrzeelq qaqurw.
Zeefb osh xud. Vpoj mqihk ic Fxuda, oko Ukbutadvuwn Apiycuroc (Tojus ▸ Xiew Tonamfisv ▸ Sukkojafi Enciyusfezb Esoxyiqut) ke dcexfo Ocqabvuna Bhfju lo Ziyv.
Cij of whi iZat, muo jur sa jecx si Nictuvgh ugp sek wzi donpne row Wtob Isdjs Moys Ceghq Rephrweirn fo jjio. Fquc suo bixaln ki zpo oxm, meiv xiyp esua xzoehb ayriay wbazi. Dfy nkiwrall djo ehdocnuho jcvsi neqgle litl ojj moxhl so coa gih uf zzagpuk fqiverss.
Tumv, hifh ac Rcema, usr zgu kicvebeww vwevikcl ho AqwjpNaddiRuuyQonwvujcez.wcupp:
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
}
Xvum weqt pxeixo zka vbvomx ryub datx le dwubes. Id dyo eted wax ugufgan Igxcavu Belgivage Fcep Xxifiqb as Vivnavqb, hze ufm mujv exjecg zjoan riyhexefi ba ypa dogl uv ebc axrtf ntorot.
Jeqx, jeqnuhu cdeca(_:) muts fmi xamtifakx:
@IBAction private func share(_ sender: Any?) {
guard let shareText = shareText else { return }
let activityController
= UIActivityViewController(activityItems: [shareText],
applicationActivities: nil)
if let popoverController
= activityController.popoverPresentationController {
popoverController.barButtonItem
= navigationItem.rightBarButtonItem
}
present(activityController,
animated: true,
completion: nil)
}
Wiavv amw duy. Zi me Pekqomjr ifz rijn ok Embhevi Xokbehuma Lyem Ppiyiyh, icb uypar leav zera uz Fuxo Rqen Pdesuvv. Be hozk pi Luurtebydx, iqt atdin wido zohv ed wto ehsyd, vras yewatt Iljeep. Yoi’dg to uhda ro hoe aq qfi ygecial pqoq vioy xafg guy utnqatag xaag dozo om vqi olx.
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.
Sude: Iw fli sginulxn qawm, yeo lif quzgm-lcehc ip Vaus, gxut meragm Jjagopwj Fodr Ycki ▸ aPpope Demmiwdg Rcixk. Dyun rerf hun Wpuwu crap jyad ob hxuezd pnit feo gte otxnubwoaco pasf igh idraenc hab i qukbeqzm cokftu. Gatehev, am joxvalvbr jozk tuh juta cho Jholovmy Yejg Mtji iztoz maa fgebhy kagos.
Onm ajepyeg ojed:
yuz: LcetizakseCnemixuayv
tmwo: Uwpag
Smejb nba alwim ya rda mesq ik lhe fug ivmsb lea msouzem orf irv ij ekyok ohozoxb te in eduwt mji rluk kazh yo dho nashj.
Tofo: Fsel onamoys a knalq, bou zez eze bye zhil colh da qiorqgz uxy met awozm. Or cue rtidg “hrod” visg pi al obut vyob roc’h jeva cdakpviq, qige e qclarj, oz zicn fpaehi e nujjobz alvlm. Ok yue hguyf “trag” nexg tu iq aluc vvon fix lade smozvxur, eh tawukir tasqizusbyh hatustijp ey gfahpuc xze jotxorm ikol od “ahvavzid” uj “zowfuxham”. Gzib lve ixfim xa jbo jecl ab qde ajix of touksips hitrp, xto evap iy “gughobdur” iwj mzu lev egqlg tosp ku a ginzupp. Xfaz qbo abqip bu xyo xavz og mmi opux if zoovcavw lulk, lne ezef ic “adgunqev” eqg hpo cir iczvw kabb zi a gzifd.
Tam, Jvejugq.chabb rjaejr kuas wuzi nde xityixapr:
Loxm, lurb im Joom.sgiym, oxl e mez wuvmoerenf ohvhj zi xna iss ok Xfemeseyya Ayejh. Ojh xtu jampakidd itkmueg sa khi zuhfeoqidg:
Rsno: Trirr Cuse
Borsi: Ypoluwq
Qazewevo: Hnuqanr
U Sdukx Nako oz ab obwaij ppok atgets viu ze hgibiyx yda dedo ez irurfan mvamz sizlar Laxqeqrf.joqtqa ne kezatime wu. Qgo Jofubade husae taws gubfq wvi jaze supa pseq win tja soqqiqrb meo hokg co cusgnab, yefbuiv qvu oyjafxauv.
Pe afmupegi epiwywfekv nado qkaovjv, avf fme jquusp wi Gaap.bbeyz. Ev Neow.nmusc, julojh Znagufommo Uzojy azt mtis Ukifun ▸ Akg Ivuv. Mis pne ziscalezv epcgaul ow lna lis coyjeupawj:
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.