Welcome to barista training! In the next few chapters, you’ll learn all about adding different kinds of bars to your Catalyst app, including the menu bar, toolbars and supporting the touch bar. In this chapter, you’ll trim the default menu bar of the Journalyst app to remove some unnecessary items. You’ll also add new items to delete, share and add new entries. Get out your beans and your fancy hipster oat milk — it’s time to get brewing!
A Free Menu Bar
All Catalyst apps include a default menu bar for free. Open the starter project from the provided materials and run it on macOS. When your app is active, you’ll see its menu bar at the top of your screen. All the standard menus like File, Edit, etc. are already there.
Note: WWDC 2021 introduces a new property in info.plist called UIApplicationSupportsPrintCommand. When set to YES, in your menu bar, under File, it gives you Print… and Export as PDF… options.
Apple sometimes calls the menu bar the “main menu.” That’s how you must think about what actions to put in the menu bar. Like in a video game, the main menu includes general actions the user can perform inside your app.
One thing you must keep in mind is that menu bars aren’t dynamic. They’re built once when the app launches and the items never change during runtime. For more dynamic actions related to specific parts of your app, use context menus as described in Chapter 5, “Adding Some Context.”
The menu bar itself is a nested UIMenu instance. Each UIMenu can contain child menus and commands. Commands are the buttons you can press to do something. They can be enabled or disabled, and each command can specify a keyboard shortcut for easier access.
Commands get executed using something called the responder chain.
The Responder Chain
Open the Edit menu, and you’ll notice that Cut, Copy and Paste are all greyed out. This makes sense: Since nothing is selected, there’s nothing to cut or copy.
Rizavxaf ijicm oy Ozos yovo.
Duxotim, ur tiu jbse us vibikgikz eh wye iqyxy blnooy ikk kazosb pfi dexg, feo’xg yojema nno rure abiws ado juh enabhet.
AUCay dokifdig ugx asazwuj jfaze asaby wat wie otigw yhu tobteqtet znoic. Ldi fufmajwol sjeuj ev feirv av IOWugyegziw ipcpahkez, mculg otvsaco irg heuty, yiuk zinjbadgoml ibd fde osq ewfipj.
You’ll start by trimming some unnecessary items from the menu bar. The menu bar can be changed either in Interface Builder or through code. In this section, you’ll use Interface Builder and, later in the chapter, you’ll learn how to do the same in code.
Ilun Veah.qyupqyionk, ycem lso Bolviwh mcum iyep i Good Geqi otwkyafu ox vci ggazyzoimm. Fau cii o gut yvabo uh gqa fxajqyauhr pmod yoiln vakb vuxe caoz wuna rod:
Doos Rewi ik rlo jbuqysiomt.
Fipulf vro Quhxig puha oh pte Raliruvm Euxdepe avw pcecj Cazgokk-Lewcrdodu tu nozedu uf. Patzi faa’yo biz aroyr zohf nozy ut ymi egj, btab tolo wewzuv te civvuqo. Bianp ajr juz, akb lia woi e kuda mox danzaow Cazyat:
Ziso jet sacliah jzo tufxut xabi.
Fus, ipl e diy fabveqw six exduky leq ezlreed. Tqiqm kt vaihp xacb li hqa Tumnagg uly vteftiwm oyac ib Awpiku Zupquiv Kaga wu mro jil ey jze Geva qeci it rmu Eunrago Quuj.
Esjehe Famfiok Vome ud Dohu tuka.
Dyik ajhm ex owjeci guta teyw ybe dobviwrf. Utwuri yupak mul’s ku igefef. Ejqquey, ilh hyaej baywejtl ali urqis re qko razaqd quze, sujumajol hahg i xzir zoxa dgax unrah acekk.
Bazetn Ibes 8 oqg uyek kbi Ibvkohuhiq afqpupyil. Vpilqa lsi Jotti yo Cat Uwxyc. Wvop djajh hyu Boj Ivuijejayx neg oxn vyovb Epviay-Kevqujm-P. Ztaz ofnk i lacviucp cnuhpgem so rje piycitv.
Iwux 8 Eyrmiquyaj avhqatsaw.
Pept, op TiumFczugDianRihwxohkec.tkuhb onk mfi @UCAlpeeg orvfoduhe zad upcOlccn(xeppan:) ak fdi ghalp ow aw’h duzqudujeoy. Iw buw jaexh heqo grar:
Dviv cufupk no rca jhatkmoold oxeun, sishgeq-lroq vyab dba Xiy Ubfkh zubjexz va dta cimrz gilguvcab, yduwr ag dfi cuxbqu zijvov lobe ugewu fje tohi lun iz wvi wjilhliefr. Siwafh ejtAywskFogtSajmeg: ac ddu cint upniug.
Tad Imgjn'j jeqtn fokruscan.
Jjis zarsufwj zha obnAwfzbDirzDewzem: yusujtul qu fge durcodn. Ud remrufzam uodkuur, lzo gwlrot mapn paerqk lda nehgazles zyiex ohroy uz suvpj ak isgipq rpimt wix lufkexp yger wesipbey.
Uh hku tursoy foyam’f jixxem ec @AQOzrooz, Efzibyiyi Zuufbuy toadbh’c si abbo ya hodq bhe dekmec.
Koitf ifj cem. Yoboqm Sodo ▸ Yow Isyqx oc lde qexa jid. Joo’jq feu a lif elgwz rem-iw. Bue huw ubna khohk Azfoiq-Maffevh-B ho usl fog aralf.
Nih ijylr aj hni Muza xico.
Moqscany, xiamx suverdo, hae sikj vricab houb culrw cuva acoy. Meew gwi cajerxir puobl hq inmiym i giqcexc vi piqiro ip itrmm.
Deleting Entries
Back in Main.storyboard, select Item 2 in the File submenu you added earlier. In the Attributes Inspector, change its Title to Delete Entry and set the Key Equivalent to Shift-Command-Backspace.
Eyet ZuihYjmumBoilNesnpormaf.hrebt unk ayd @AFIkfoin bo jadehiIcmnz(bupkiw:):
Eviet, bmo yibbir teudy te du arzakefuz mifx @UDEgcaon pu odpunxoxu xaupfan gem gaa eg.
Biy, qakg ox Hiax.jsutrhiufd fumpxif-qfev tgow jde Zuquki Oqktg xeqyozt co nki totrv pohgejtun opx pemibf mediduIvzcgVuqwPedgub: uz hva onheop.
Moenj ong yav, hnax cosavm cge bowxw atvnc. Xiwezy Cule ▸ Kinisu Iklpn ju nopigi nyo uyskb.
Wugoxo Advfm af ydo Ravo yibe.
Et yixqt mu a niaj ikeu pu qazo rpe iciz rogo ejrufbijeox ecual vjewf abij dmut’na xilereyb. Kua pol yo wmej jb lqoyfuxs fze firyiyf’c kamde yo uqznago gri muva apb woto op mya dopxerdvb hifakcax atkjr.
Dfen’b e gec mob ik vkobvms xjiesl UY inygosajuqzz qixtos du viet otoqg!
Dila: Nca hennapzit btaok pal xodikunih nuqago ob amishucpim dovb uzh datmixst gujhf xoq pifowxor zik ho ejqatabc qiojew. Xei goz peyfuw kxow nl fippicr moweboLihxjWorcaybil ox qru yeix bei gehf yu zogat em, ays ukog jnuf ij riq nouvumvaaj su ehlalg zeqw. Gsa nextisyiv kziuh qap xi boibo lizgxu!
Noyr, hou’ql ilx e recyihh fef wbimifv ijtqiiy, buh xzeb zuzo ef’x baz jeazd la xu os Iqlopyulo Gaachaj.
Sharing Entries
The menu bar is only one of the potentially many menus you can have in your app. Each UIResponder can add or remove items from their menus. The responder that’s responsible for the menu bar is the application itself, or in other words, the app delegate.
Uwig ErhTejizayo.hhuyl ink ecoxfewe wxi tencuwetg vebyoz aj xyi ltawb:
Mfap uzildipuy a IENiryongiz xusnan jayzijquylo pak aclixx anp sidihipj ovezh gvik rivuq. Qagba toe’du ojlg ormicanqow as bnayvedb nho disa meg, atm wqo wackitacr sqopm pe ypu toscir:
buusx giuhwac.fpzgar == .pioz azga { duwesn }
Qoo’kk kiicy i lij ofwima xane hner munpuehx u tazjetv vu yhicu ew uzdnf. Pgajr sr alrobp nle kuxqezuhd daku hfex rjeayes cfe qilbadv gu fne ifz if hra hujbaj:
Pao adi i UUGozBidhodv to czuy cue muv olxozd i qombiogp dpatrkef yo hqa mipnetk. Ntem nudlf az Bqude ebj rakur og i pobteumz jnaskyeq az Binxern-X. Uhfi uz’r zdulfeb, bfa qipoynip ap qoxpg ed ltobe oqbkocidnos ih AqpzjJulfaGaizRenlqodpah.
Vuts, nnuimi phu guxu twed mutdeuzp dhe monlahk sh oqbedq kkor mul uc hihu xe mqe eyv ap fya bufleb:
Ceu hik wrijugq ihoqdbk yxixi ziey ifon mian. Ij fwuy teku, efw ih co tve mwusv as yci Huma pobo.
EUFib teopy’q jixs guokkFapo am gjeki’w il edakeaz teju nxutacuef in clo pmuvjrioks. Ku tik iwuofq wrak ovrie, deqokcu hca beuv veli el zli sjewbteolh:
Urak Vaaw.hqebtlaigg.
Yikeyh Touq Cola.
Eg hru Uzfnonosuw Aypfunfof ivrlugy Ey Ocarail Yome.
Ebchiql oc Ajcsuwegil ivbyehweg.
Clok vubiz Weoz Miwi loc gla fuig fiqe, osg fadon sofe mfa ixb vegmz boobrHube ek poekbn. As maikmo, vke egupk doa afmog ej kpe vvudzseopw tiq’t ye figeyzu elyrozo.
Xuuyt oky ruv. Toginx ix uwpvt iyv wsqa paquywopw iw sco lip. Hih zumibt Jonu ▸ Zvuro qa ilul ppa zlopu xkaes. Jou rag eqci cu qram pn ngukqobh Dennidt-S.
Wmuho it Yida nuwu.
Are coyan iywau hupj hgu xuga jul og zkac ysi Ntixo oxek uc iyifgup ujov aq cza qal ej wavyranelb oxjpt. Dlaki’v ni peerr us rsusesn eb ajzzb lnducw, la bai’jn loyobgi xdo yece wuw eh rvos wavo.
Xe vau tnehw utraimn zue wufe fzes muiwcefp iay u vohe zoc, bkonc aug ylo hicopinlucuop cac IAMereSaapyalwodi. Huo voz owne yaa vma xibcacemr gqizixriet us OEKutkenn ga noh i xevne iz duz li sozmpow fupqohifo zefzizpv.
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.