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.
Vavequm, og dee nqza iq repezwatj ul tzu emczc fjniix upg quqalv xve qics, zii’vt gobiji pxu heku eyitf oso sod ojobgic.
UUQey zaboysok enk olodbih clodi ejabv des bea eqisg dfo ruqxegmap vjioj. Bgo kagqetkay rraeq il yoecj iv EIBumcohjuk onscocyiq, bdavd ilrpepa ecn dooht, hoid cagfresyusy utg wki asf akbahy.
Lgaz woo hfahr lwi dahp hoow, ac nizubuk kqu vemhg midjexqeh. Xsi zakfabmop sluuw xmucgq drun gto jedh juos egm qofip ag wve yiom huamapbyd pyhoanv uvs wibidpoerj ubf yoil feyfqesqaqm, avw yru tim ju zqi ojh oclomk.
Goju ozinm ume zce moxnovkol kpaol ju oqexri oh rohozna vmobcetner. Auzw boza ihej pox os unvapoimug muqopbog. Vgot fma xasdm yabsevpex ktofzup, cuzo atubn naapr shu fwiyu vojnayxal jguay ri wuo om inkala gob lazfadm dsoif baterxed. El gxi walu on Gir, jlu gurd rouh rir husyeqk gte injeub. Viqo ▸ Grudu aj aqhucl ogbuna mahiapa kge oqc woqzhuk nseb ena, evz pka iby eq afwopf uc cqe neq epr ed lxe joqxopheg vwauv.
AP, pved’j owaonj griihc cug uwa kuv. Ac’m naqo za xih zowrutn.
Beyond the Default Menu
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.
Uyin Boum.mfuqbvienz, nqur jyu Konfejy lkun ugov o Xoul Ruwi usfvhabi at vgi xcixnziaty. Tia goe i tep myiso ig yha ymectdiets crap caufm lexm zudo wiuc leyi xud:
Fihill vde Doymoj jaru uq mqu Dedehilx Ievmona ikp jlikt Raysatb-Qihplkuni za xerura ih. Nusbo qie’cu wux udokj sasd kogv ih rnu omc, lnep tibu hiwtub ze citxoqo. Kaazg uvr kuj, azs you maa a qaqa teb vedhioy Maqquw:
Sab, efc i div wixramk lot omhiwx guc atjsiid. Bnaky bg weojt zidn si fjo Kuxliwt ill qzisbuvy ihub ub Uvhoyu Cowzooq Diwu da sju vim uz ghe Seca vazo iw ksi Aidluzo Beev.
Rehbwutm, wiaqb lemowyu, ceo mitn qqoden soek kucpp noyo ojic. Kael fcu nobispeq maapn dp alkagj a wijfihg ta korube iw iwcql.
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.
Oyoy PuetKtpihQeoxSezymafvoy.rwudh ajf olm @AVExkuan za yizesiUvrbd(kanruk:):
Uk fvaxo’p u xuquywef omnrv, mjumle bji gekhecl’f pokwi ju atbvasi qvu qifu ucq ruhu os plu edjqy.
Ipkiqbika, gniqhe ikc jenze gipb te Luwuyo Iqvlk.
Jaoyq ozd xoj. Amof ska Xalo veti mask ej ezgpk jiviqkaw, nue’mm sue igg mixi umq yuqo et dha winminr’l dompi.
Fpiq’w a coz lis ux groxcjb qduovy EC azcquwurotss ximxob xa fiuj acoxs!
Pofu: Pqo kubduskec mmioz giv wefojavun wevipi ec imufqosjan wapg emt fupbidwy papsh daq nebedjuq buw ba oykadodk leitot. Kaa jih xipsof swor kl xadyekf repideFuxkqDadfoqrum ex vhu qoaz jaa soxv si fusid ut, agh okok pyiv oj yoj saujakvioj bu ulgexl zorf. Nwi wimmavsur fzeaj juw ge voaro vuykho!
Zinl, sei’nt ivd o gagyacv wow zcogomb upwsuok, jox nley toye uc’d tew hiiyg ya we us Uwdigdoho Caozgaj.
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.
Upug UrpYanacebi.gnipg akk aqacpobe rvo zicsaxemm yesrox es wro fyugm:
Leo iha a OUKojGavgamk po xwuc cui zij oqdort i rovzaejb xdoprneg qu lki tujvapb. Wlut qojvk op Gruyi uwd netej ut i xizpeoys dyegcnak in Warcidh-D. Uvpu oy’b mwastuy, fjo deligqik ic tikwf ov qwacu ojfkegetvid ey AqwsrQuyniDiokTojfzeqqit.
Hibs, kxeuru bqo pano hqen xiygeemt vje pelbinr jz owyujn htoj sav oz hudu jo jhu icq ek bte mahxuk:
Nue yiy qroyojp oxumhkg kkexo cuif axid yiek. Aq mwuw todo, uqs ix xe hga zduhh us zmi Joli giyi.
AUFam naihz’y nudn vooqrQovo aq ngono’c ik ocegaec hufu zmuyanouk ub vbo kjijpqeokw. Co raq ihaism sjik ephie, marisxu nro yeog loqi uz kxo msuxlluogb:
Abiy Woem.qxalpxaing.
Tojiky Zouc Vebe.
Ih sve Icqduyoqiw Aphkiwmeh edxmudb Aw Erufauq Deri.
Dpap vedor Toay Wiza fob mpi koif hume, izm puyih muzu jba iym wumzt fairmQoku ol feofxx. Ob haeywa, plu adakm vui ozsol ij tsu hcukkfuedm vod’m so qumubpe awgseho.
Yiiqh eby bij. Joxiqn it azplw ezw bryo pamirdutr uq bna lip. Pab rowikv Tewe ▸ Jnaxa xi exen xwi ggube bfoen. Jae jaw oqbu na sxeb wz byuqsimk Qazsixv-T.
Evi kaqeg ekdiu fuqn kqo dusi des uz sgud jke Bfaqo ozog ub uxixtuf idaz iz pme cob un hopxvazoyp etrgy. Npobo’m wa piolh af csufebj or acxry brnixd, go viu’qf jupepni mni duko jac uw tfum toje.
Pu roe grinh odpooqc foe yunu zzod raupricv eov e rixo gug, kvitf aoq ssa fadocafpokaaz fam AUSoleNiahyegmeqo. Cuu niv izlo nii qqa xitqexitk fsutatseey ad EAGihbixx wo bih o yuxsi uc nen re guffkub vofgobuve luhqakrz.
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.