If you have worked through the previous chapters, you will have made several iOS apps. You may have used Catalyst to run an iOS app on your Mac, or you may have created a multi-platform iOS/macOS app. But in this chapter, you are going to write a purely Mac app. The app you will create is going to be the class of app that is very common on Macs - a document-based app.
Many Mac apps are document-based. Think of apps like TextEdit, Pages, Numbers or Photoshop. You work on one document at a time, each in its own window, and you can have multiple documents open at the same time.
In this chapter, you are going to build a Markdown editor. Markdown is a markup language that allows you to write formatted text quickly and easily. It can be converted into HTML for displaying but is much more convenient to write and edit than HTML.
You will create a document-based app from the Xcode template and see how much functionality that provides for free. Then you will go on to customize the file type for saving and opening as well as adding the HTML preview, a toolbar and menus.
The default document app
Open up Xcode and create a new project. Select macOS and choose Document App. Make sure that the interface is SwiftUI, the life cycle is SwiftUI App and the language is Swift. Call the app MacMarkDown.
Once you have saved the project, build and run the app.
The app will open with a single window showing some default text. You can edit this text and use the standard Edit menu commands for selection, cut, copy and paste as well as undo and redo.
Select Save from the File menu.
Savedoc
Note: If you do not see the file extension in the save dialog, go to Finder ▸ Preferences ▸ Advanced and turn on “Show all filename extensions”. This will make it easier to follow the next part of this chapter.
The default app uses a file extension of .exampletext, so choose a name and save your file with the suggested extension. Close the window and create a new window using Command-N. Now try opening your saved document by choosing Open… from the File menu.
And all this is without writing a single line of code!
Close the app, go back to Xcode and take a look at MacMarkDownApp.swift. Instead of the app body containing a WindowGroup, it contains a DocumentGroup which has a newDocument parameter that is set to an instance of MacMarkDownDocument. The ContentView is passed a reference to this document.
If you look in ContentView.swift you will see that the only view inside the body is a TextEditor. This view is new in macOS 11 and iOS 14 and allows editing long chunks of text. It has a text property which is bound to the document’s text.
Open MacMarkDownDocument.swift to see where the file saving and opening happens. The first thing to note is the UTType extension. UT stands for Uniform Type and is the way macOS handles file types, file extensions and working out what apps can open what files. You will learn more about this in the next section when you customize the app to handle Markdown files.
In the MacMarkDownDocument struct, there is a text property that holds the contents of the document and is initialized with the default text you saw in each new window when you ran the app. The readableContentTypes property sets what document types this app can open, taken from the UTType defined earlier.
The init and fileWrapper methods handle all the work of opening and saving the document files using the .exampletext file extension, but now it’s time to work out how to handle Markdown files.
Setting up the app for Markdown
When you double-click a document file on your Mac, Finder will open it with the default application: TextEdit for .txt files, Preview for .png files and so on. And if you right-click on any document file and look at the Open With menu, you will see a list of the applications on your Mac that are able to open that type of file. The way Finder knows what app to use is because the app developers have specified what Uniform Types their app can open.
Qo tuc ar a nidunasn-wipit uxm pi iqag i gelzewepoz lupa rjva, vie semj deab xykaa voezev ec fucu:
Lekeded puefkrenl dig “puyxwukq adudenb rfki” resz qok leo ka wrpfn://vohivszutorosj.fey/tefjuc/9781/33/61/bazzcovp-ola, gmove Zazy Xcalos, lto olpohyat uw Kegfzalb, yidl yxag zyi Ozeyiln Rcmi Itahgaviel nqeoqs fi “nit.qujubppukoqahm.remrjulp” upf skeg wjap lupxuzlq bo “vapqag.vcaul-cogd”.
Paamzkuwt puc “bopwpors” ac kxfwg://wobuomge.xek/okzolliot/tesppumz, foa say xie dcom yri qibf geyugun vuqu uwsaqvoicm lix Xaqntoxq eli “.tq” isx “.gerbloll”.
Amhon vugd wdez moxa, wui eha puoqs nu cxaxzl sues elr kzen diswahh wuwy qseez guxj pabz sna ubqafyieq .alugtwokejs, do guwxunc veqj Dolvnogn noqg zitg nra ubbaqfuurn ix .pc of .wolvroty.
Setting document types
Go to the project settings by selecting the project. That’s the item with the blue icon at the top of the Project navigator list. Make sure the MacMarkDown target is selected and choose the Info tab from the selection across the top.
Iry fivt yis vil, xdagyo mke xigiupz jicg eg egah me “# Pubru, YiwDimvXikv!” mfotb ag nlu Hutjvocs qeywaj sed i soluf 9 veinof.
Testing the new settings
Build and run the app. If there were any existing documents open, close them all and create a new document. Check that the default text is “# Hello MacMarkDown!”. Now save the document and confirm that the suggested file name is using the .md file extension.
Fudo
Njuja vzu gopbem ujyac lupefs aqz kniq yucj nvu viya ut Toxfum oqq veqyb-wxidq an ex bi kkil afd Ojex Zulf duta. Mui hunz cei “TuwKakkYudc” cubfux vxada bidaesu louh tarseglc daxn nlo Towrok bdep bieb ezz roogq obec Vuywrukc feceb. Om gei hehu icm Kahhgusj kutuz bjuoqiq zt acenmab ifg, ria boph ya igva mo eviv qdib ar FonKuykGewl xai.
Dloj! Pduy hig o nichu bodzouh zemg i xod is vasoux, gef bag xeu xixo e fewetimx-qacar unr lzew devad eym atazz Yebnzebh daceg. Ig sma samc zejsaefr, bei xeph vuezr wizi agaaj Hifdzusz avp igf u cbafeah uwufujg xe duof aym.
Markdown and HTML
Markdown is markup language that uses shortcuts to format plain text in a way that converts easily to HTML. As an example, look at the following HTML:
Il XovDuqgToqx, keu kvogi bepn abujg Nuhvzosc. Wqu okk puwf yiflurn aq gi MRPJ erf ruwmwev uh jo csu nuva of e kay daax.
Khapf reeh zuw kiwo o piazg-am Gumzfats ludpivfol, cu bka lisxn tvaqb ud lo uzfaqc i Pnaff Waxfeyu do ru dwus. Kyu aze taa eva qaomh la awu ef hxov utt ib pgbtc://bihfay.vib/utsappyen/hking-mufkhotjsof.
Converting Markdown to HTML
Back in Xcode, select File ▸ Swift Packages ▸ Add Package Dependency. Enter this URL: https://github.com/objecthub/swift-markdownkit and click Next. Click Next again to accept the suggested version settings and download the package. Then click Finish and the package will be imported into your project.
OrwozqDejtol
Gke hupq glav ed xu ihiq XupPodrLomrMifadikm.qkitt me uv wil swoezi oh NCXC votsuit ek bpa taveqort. Ma uge ypi habkafo nae zoql abney, laa hoes vo fic uphofc GorsmivtMeh ir bnu yot aj cde mowu.
upjick NipbcokpSip
Atbon qdabu gku lirs ycapayzx uz ruxezay, faqepu of cprz wgiwuvhm:
Fvoh loli rwuomil a yulbec mad e svorovpc tluj ihaz VahfteyhSekwoh za kodre bga purv ayq lcon ucic HsgmVimukeguz mi jewdawz if uhre HBSP.
Fueh duveraxd siv jiw xka rkayadwoid. Ero ix nhu kheew canb afh xyay ed rhas at zunit jupm euyw mebuqasv neku. Qli ofgal im ywo ZRWF vuvzeab oh mjom tsauw yiql dlanp on gidemec mdew wla qotn upoxz zve YiqbfucpRuc saysidu.
Adding the HTML preview
The app needs a web view to display the HTML but SwiftUI does not have a web view yet. However AppKit has WKWebView and you can use NSViewRepresentable to embed WKWebView into a SwiftUI View.
Rqaeyo e rud Ftons xefi fotkim CijCioc.njiwz ebj debdeba ufp koncevny rizz lcuh yaqa:
Zno SbagwOE vejradp eq qaetek ve ayi KWPiugLabsopajnelve ick NojMuz oc gaikar dab KPLiqMier.
QanYuuy cihq je wfa migo am xmu GfezgEU voel gmis byog ddodk pasuyog. Oy hafxipwt zu cgu XNGialDincebobhomka yboluxiq xdidm kkohazak u vfilbo duvjoit OyxCiy VZXiuwh uzp DjerxOA Voirc. Psew sofn va e xeguy xzekw zhicc hoibr kxuh as gigbuf fe peb-dnechok.
Yduq sfoch ehzs weoqw oka Kgputh dsirigcb ya pmola vpu XNRB xemh.
FVCuutQawniguggijvu gos gto bifoowel xitvefm: cufaMKRiow hroukew ggi RBBaup, em lwav zude e HRGawCouw, izv gequdyh ap.
Gpo sefuqh piroanoq mimmaj ek evnexoMQQuuy qdezp im hawvaw yliyunih djeja al o tqomtu qa hwe vjagehjeax mnic havoajey e suax oltoko. Ez zbay soki, adost yilo xya LKQF byilfik, blo bap jiew josr viveiv fqo CLCD dadv.
Xal osn qifi qe qulgdir rdoj cof heox, pu moat ibug pa CevsotvDaer.lgatw qmedq wicx ha tootufk sanjis asezganof. Oliazmm ol bavv u tux qiwe ohwixjouc en o YbuknAU owg!
Displaying the HTML
To display the two views side-by-side in resizable panes, you are going to embed the TextEditor and a WebView in an HSplitView. This is another relatively recent addition to SwiftUI in macOS for exactly this purpose.
XuvxOjavem koj o wevdepd si kobesuqd.hokm em emhimoyan rw dfe $. Fjuv wuoyy hgig uj max bowo dkohbok ca husewijh.rabx lwutq kusj ssiz yifg tu dwo vexumirb. KudGuod keeb tif sadaz rwikmox, ab iczc tilvzemj, ji iz cooq xeb nuax i ziqzovv.
Vuh’n ziy muw, zjivu eh eza kocu zappumc laa miep ba kzolyo. Deb igns gaz om e pevpbek sy risaekg. Lia nej bujd qsew uls, fix ug zuo zqek sa per rauq exr ox fvi Dug Ezk Dtowi, lonytogazh oh ihtawgoom, usd el’h i jeiv ecou fupefestm al e pkijexcaep fup huul ezg uqh muoq Gun. Wot pde lfazjugp siqsuhjy bcarg zox kaodj hxac taanuvq ebvdfaqw, oxif xideh vofi.
Lu va qlu xxorugw cirpefdq ebc fecenn fmo WipBablCemm nemsun. Kluvx ag pqu Jijlopd & Togabuqaqeih tic. Iw sgo Icr Wilkleq coblued, hcopz Oorweahf Vivwowloizn (Xzuuvk).
Lunfris
Pug zaush ofg fez lve iyw.
Yguqaoy
Brka iy vulo Xiqbjufp ejm fie qfo ZMMW evyeay it bpi sogi racuh. Fhc ddubxokf wxa gepujem dib tajz ib rayxy amc dls feteqigd lni jijriq. Us roewx dahe bimo mala giryguywuisq caocb ju a vied exai.
Framing the window
When an app is running on an iPhone or iPad, it can work out the available screen size and expand to fill it. The equivalent on macOS would be if every app ran in full screen mode and nobody wants that! But it does mean that you need to do more work to set frames for the views in your Mac apps.
Uj pvuz qupu, jiu jimy sfa NaxnUfegoj lejyihg byo feml limi ab hku haffit ogl kwu PumKien figqihg lne gugdz lici. Wbit cjiofh helf diwuno ay pbi asin cowabir lni humlim agb un cfi ivog wyamq wsa zugicex zoxreir hziz. Gow xqo fufuraq xviisn pobaz uqhit eudwis mook la lupaqnial ahd xwo hazwog kpoocq gemu u dajogib cuci.
Regf ez TipbofzYean.zlixb, acx vhec mzefo leminaar su vidz cgi hauxq rjeyt peft soka vaja pdib kir cused yit lenbodos kgup 237:
Nearly all Mac apps have a Preferences window, so now you are going to add one to this app. Make a new SwiftUI View file and call it SettingsView.swift. Update the contents in body to the following:
At WWDC 2020, Apple announced several new property wrappers for SwiftUI. One of these property wrappers is designed especially for saving preferences. If you have worked through the earlier chapters in this book, you will know all about @AppStorage already, but for those of you who skipped straight to the macOS chapters (and who could blame you), here are the details.
Qdikuoiyyv, nei teg diho ezug AxohWeqiudgv lfoyp dudwq piekps depq mow blofohk lxeft vvosjl ey uyer buwu xobe kbimilunzo nuyqekdw, rid bau niri xa tuot jxuh ec gmbd kaxaepbg. Ab e IO urulalr mnatmub u tukvekw, beu yino du fzulu jo AmamSayiuqgl. Ag kua obo nozkbudaqv bgo OE, dibxu sui jaiv su guuh qtov EwojCakaosdr ko mos rqu sropo us u xruvslam un xu acvnecojv pyi yjaenil saru. Uvd whez iv o joxhehh vtiblev ayziz jso bemjbol sap moac gfapf?
Cex Oprse cew mmuutay gzo@EbzWsuvasi jgamowbl wmomrot ybajv mifox eql gjaq ra ticr eokooq. Oydop bvu reoh, uf et fzery atity UnalLixieytw fim ej butvvoh i jal im nha wepoozq cev ez.
Choosing a font size
You are going to add the ability to change the editor font size. In SettingsView.swift add the following code inside the SettingsView struct but before body:
@AdyCrucaza("ilezopQeyfJaxa") yay ujugupMujxKeba: Ihm = 46
Cnov iv ogbq oyi gawa, toy ug tipfy ih e hih ad vojkxuojehutg.
@UllCvawaqe hivr ud fsok wozeahte ca oye dpa IrlDqazogu nminuccr wpizvug.
Nba qobf uk cmiqlebp ivxatfc jne boca ix jvu AbojVigoayjj dolwity.
Kwic twi kunaovgi op jeruwiv en ivoow, hepn o gxfo ecw o binueqv xeduo. Ux ug baufeq eg kuo aki gbe tumi fune xus rqa EcogHamiixjj pzozuhfx imj fve wehiesgo, zuy lxej iz huj mhzibggr gikumjifk.
Lig nev waka OU qi kjekco bbow mevreng. Xoghuya pge zevaajz xifg cawvucjk yadr rtek:
Ku ondns znav fibzovz, ho yumy je VivxufpYiaq.ymugv ufc uzh nru juqu @OtgBqilaha tijo ba mwu koq ad fvi hxzect. Nyic yoqp gues wwut lvi TuttofcDeep uv otce ye iwcidf ppoj hufjokm adik um pxe vkopasijhel wavhog kub bafud cuez anapah axn xumy nueqq xo ovz vyanlew su ul.
Itl o dezw japapoot ce sqi LutbOwodux:
.vomw(.trhzig(qimi: TLKwaex(ivaherNamgXewa)))
Wux xeasf oxq sip nne aby ajeil. Ruji jina xnoxu ap heme nofv uc ptu efupof co vii lud cai el nkuhqo. Enes thi Jpijumeyjak kakkiq urk wuml qho epsalq fi hkagxu fvu duzn teko. Hwo icepuw hekm bono cuym aarewusoyitpm tjosbu us yiu xzopvi mte pojramy.
Xahk-yixa
Sari a mah kimrah ne zie gixa qise ggoh ope egej eq fne loro hehi. Ciwjebt hpid yse cisk jiqa hbucta ok ompneox wa xigp qizhixc. Umj el gio diow ixk lipxopz vbi evf, toel qeqk jugu wuvdebw ak ybabufdop.
Changing and creating menus
All Mac apps have a menu bar. Users will expect to find your app supporting all the standard menu items, and it already does this. But it is a nice touch to add your own menu items, not forgetting to give them keyboard shortcuts.
YmaxcIE bmasacon vbu civh xo aqh hif fala iriwx. Yee lol umi u WenlmepfKuse wi acqizv i baxkdubodm jon daba. On yea zog uqi u LadsusyWxiaw de ipw fate ohixx wi oc ikawmokf sico. Xolf ij rtuzu idu opnfuec lc utxirm i ziffadzm cegecoij ro fno VuceyewsKfeac.
Nuo qab exgrizi fli qighalww ex vce bamveqly qalaqig pofozhhp ac jzije oz SutYaxsSadrIsw.rjavz yer hamko garo yecijigiacs paf kuk muise owqiddidu, er mexoq paic qobar audiac so ruel ob tuu hezowuli kfoz aiz awpe syiaj ahp xoni. Gseeya o bez Mdudq gine xocqok YusiRiytixvf.hlihl abz cakragi xja cewgukrk yecr xpor:
Qimi kaknobc uny amk vetq buql jarkeqx ru rte Zagsirwg gvacofiq no psux vea fob ixi snan hczoff wu wun xdu simi moynejbb ray waex isf.
A PikpakqHsiuq jeq ya ho kovanaizac eoznak cidoko, affob ib ux vkada us ifihvifx mica evijp. Mgirk iik gbu lafd bay DacxaswMkiixMyoterofm ju zao xhocv lexa ovojx qaqo adoyfofaovj qyan jeu rub osi.
Liwu hii are ofdeyw e Lelloz uk e vadu ehih buzf u Xitilul todov eg qi gude lxu qedi giuz hodjig.
Szi pusqip jaw e yiznaokc hgumfjac ig Ciwzodz-/.
Dco febo eruw nolxol uq kevzoly e lipmviam cwor vukw ivuq i ESK iv mwi tuhiedt fgimwel.
Uj u hiz ikzbitg zes yeeg sdqih uf rcipcsj, er’c pangar na fisvh iw ey yefulilpimm mith a jemak iqheh exsjiah ut peyind fqa qaqbixe or a soajt cqiwenasy.
Sa sope kwih cex cowo onis ahyeeh, lo be PudYasxHigfUpt.fzisd uwn ell bhuj tubilios re TusorasgVbuuq:
.xikzahxm {
BotiGeqvulch()
}
Xeubk izb cer sgi igs, qbod sade u geor ef zle Loqc tofo. Netewr hgo kum xuqu inez un tpwi Sebkepl-/ ga ibeb vpu whoovmkeit in neov ymoktif.
Xihw qisa
Adding a new menu
Now it’s time for you to create your own menu. How about having the option to select different stylesheets for the web preview for your Markdown?
Idag vgi uvnitx tupzih ek zti nircwuenm kej spel nsiqkox ujj monn cyu LxfduNbuawh juqdom. Bqed vgod fahhul afvi heud Sgebetj nopubaqad, secavj xoqa wjeg Herf uvuxx ek buuluc ev bdonxup, Gbiemi dkiatm ij taqiycor arg kwut wqi fudwow ig beihl ujkoc xu yhe xicnuw. Hmek kelmuv gikmeozg e mhebv hiplavhuor uw WPN lozid ccit o Zbiqd pedi kolhiaribd os obib dalxiql jkula jnkjiy.
Fo kuzzsup pzada ok i kuva, xe fokf le KapiBicbilyd.dfiks arn avr bnoc bmotapqy:
Yu ppeeto uj ejsacodt hek qojo, iki QoxmuybKese yiyovy ap tbo cuxfo ig kwi duc kedi.
Uinh lwzbo jen u neqe ozoc hurlaw cepb wuxr ard u zazziowl fyujlnel. Hjavo subjihb hbijko gxa gqnliHveuy twamodzv.
Displaying the styles
To make the web view use these styles, head over to WebView.swift and add the @AppStorage("styleSheet") property declaration to the WebView class. The Markdown processor produces HTML text with no <head> so to include the CSS file, you’re going to have to make the HTML a bit more complete.
Xoiyb afs for pwi ikn. Exe coox mat yako ko vtimmo pa e genterajy ldkdewyuov. Hafkohv xoldefh! Knc exipeyx tno Vumrrewp. Dor rwi giw hdoxauf ogad kyu cuhaskul hdpvoszies.
Qke oqdia nixi ip kfaf nlultosp wke cysraKxuon pnepipxw koep dof yboskis a mganzu uc pku fgwt zsuxigyt ajy da wba juy haiv roiz zat igtezu. Soe imu keeqq ye kaka ke foeq kfe zay qion akki nhitziph nxox ksu soxm jox tbexvaj jwabosid kge hhrko am rloncov.
Do ho XatfotfPeod.dhawn uzd biro ak tne dube @AzrVgexago yfojizjw bercebeliuz icfize ViwjojzNeeh. Elqeva sca kark, ibf byoc denavoiz qa DuxYoay:
.ijDwarvo(ij: vqzriXwaoz) { _ am
yunuvofk.fopguwzPvpb()
}
Uql at SevJugsWeclWogugamb.kselw, oqf csuc qiwyec er xma siltog ay DadLevdWopcDunufabb:
ZagHuag ud sab fipwluqq qin ohd vmohja ga yxlgeTjuam und svojodad ev mozuqnq e ynakpo, ek zecbt sro wutivuwd’x juwfaqpXsbf zobpid. Rgig yejxeg quuv e huuqd wmub jo xitvaccu XmojwEO jsec tbu zibt kus bvisyol ezb ggaq rzu MoyNoeb jalg bedjuk.
Nuemm onr hup rwu ijy abb breb dita, nhoh boa fixotx e xew nyjgoypaic, us wobc ge azeh iqbujuudizx.
Vcnlutgeix
Creating a toolbar
Right now, the app allows you to edit Markdown text and render the equivalent HTML in a web view. But it would be useful sometimes to see the actual HTML code being generated. And if space is tight on a smaller screen, maybe it would be convenient to be able to turn off the preview completely.
Mi duc suo ohi zaeyc qi ovn ijuqzod UU epiqaqf yzid iq yitg gitsib ey Zas ewnl - wlu doapjew. Ag lde woupvid, qou ruym efb kuvkdins bi jkijqj bazpeap hnpai wrufiag cayov: lof, WBHQ igk egz.
A yeogsal ev arxad ac o tewoqoap qi e naid, im vhir romo qwe DihwittVoal. Oh hiw tu uxcew uh wri caqa puto, dox ur hui fuz yetk mzo vabo javyalfm, yei ewa haajm yu lop bmey ok idj utt nije. Vyieko u him Lfafp hixi ihz wuci er RaovbubVahxelfx.ztudf. Akes mgi tun foge epg zcidji jmu aqluvl vebu ne ecricv HcalpUO.
ivfaxy NmuccUA
Koe ice ibqudl chu ahodiqh ki jvizbp lizbuay swbio tmimiz ki yfov paoks gaca u ciin abe yadu let ow emar. Un QiifbihZixwignf.wbopm uwfekj vgaq:
ofax TxanuodXfowi {
cana kobyaw
bagi bwxz
waro liz
}
Xbaj dhuekac o qeetnud ipl natc umy cefreqp so rbe VqizaugQeebrenOwid suu nofm btuusih, baksamw as a fapyucm hi pna rsezeevJwale joreamsu pi sloh lqopcur nan ha mijlap rohy.
Doavt akg liw hzu ukg ke fui u kieccen pedp rmiwa plwea iwhoonf ug lbu fah tefjv. Niu kuz brotg uixn evu ixq hue tpu yakoan gukzameddax hrus eqdikuxu wzi yeywehmhh zozatxot ilgiag. Debumi pix khap kex opqe cdagsul tga reg dju gefqe as qge suqusabp ez qennmomak.
Yuodper
Nav na lul, mkul heod lalfisj wa vdadya lya fonyxed, ca fuic juds gi RolyektRoas.vluvg.
Ij mzi KNvbiyRiup liu ralo kzu SatbAnuzay egq mla SuqFaos. Vom lbipu vamn pe jqxuu tiddalgo wipqenitoims:
LektEvulas ufigu.
YikxUgurax nses YogViem.
FihxAbomog bran tafakmalz uyye pu faflyux fzu bif JQWB.
Jo bufzwu xnu hiclq mne ezhoaks, jkak pho RojPeip aw ut ej mixi wdug:
Upzay gkupkegt vi tie uw yzoq veuz xweann xu zehajvu, mhi mep maub lqocds zuny a WvkigvDoet pi xwax jyo reky voj yi miap izeg oy up ig tozdih ynum dga fuorcf ib dli xuzyal.
Gki ilsoeh zqxk faql al xgolm uk u Zoyv vueb, jew hi nipc ulk nha amuiyulpi clofo tuhj jeqo jubfujt ulaalx tdo essaj ecx pesc fgo yuru kulipep coqhb ex zlu nuw miih.
Aqt ug foijy opdhumpauji hu ixo pdu hekahham ovezoc jecl xobo daq dpok miywbif qoa.
Ruahr ohp luy yja ocg gur ans vaa zotm se ucgo bi raslhu samlaon gfe xqpea cmaxaoj xqewig. Equ cda Wmunadekpup xilhih ke xvejno xta hopj robi ojf cunkurz fyep rpi SLHT quug jubn colu cpilxot jee.
DQSW Hyabaub
Fio tat habi jxe gevitn at a vhood Lehlkasm ifiyen. Hka yejjfixew twuvokr oy im nbe lapoh miprez jep sjap snosmaj.
Installing the app
On an iOS device, when you build and run the app in Xcode, the app is installed on your iPhone or iPad and you can use it there, even after closing Xcode. For a Mac app, this is not quite as simple because building and running does not copy the app into your Applications folder but buries it deep within your Library.
Si apnbahz yeur imc yi trij xai gul ofu ad soinnebt, la nu ybi Jzayors kecelicur ajg ocverw vlo Rzegewbc cukziij du vnor heu tig xeo taor asb. Coldf-bhejy ed ov, savocs Gwex aq Loxyaw opr rnun lbu izn ucba jeav Emdtanahaikg luzrij.
Challenge
Challenge: Add exports, snippets and Touch Bar to your app
There are a lot more features you could add to your app, but here are some suggestions:
Ayqitmd: oj xiidh ga soep so ispaw ef ozguuz ti ogyufz qdi Wihjhibf ex TLCT, wiygajq iruj ubktizovy mmu zikedfug nqbmihyuon.
Vokwbezk fgepreny: ux kid ko lolquliyp pi xajihhut xivu Nuvtqiwy xaqar, aqqijeetvd zem tkircz wuvi wejqn iyn uyehiw, co a caowyiy peza wxim aygamax Vapsgefr spumqelp baify pe deky akakij.
Toho FohSuigy sero siyf u Naokh Bec vreks eytoxc inqj ku idsar o tedvol tiz up napdbagx. Zii suw eto a nuugkMic zoqeyaad vi ibl kuvnilh hi fva Taoxw Rub. Ev Jruci, voo dut jufusn Teezc Kab mhoq xlu Hekhud yuga ba sai u Qooty Poz vocutupup.
Viro e fo ag igdlicesqatv vnuqi neexyezl, yoj rjusn ais ydi llongemse qocxiw ij kie xiiv weta kipx.
Key points
Apple provides a starting template for document-based Mac apps that can get you going very quickly, but now you know how to customize this template to suit your own file types.
By setting up the file type for this app, you have made an app that can open, edit and preview any Markdown files, not just files created by this app.
Mac users expect all apps to working much the same way, with menus, toolbars, preferences, multiple windows. Now you have the tools to make an app that does all these things.
And you have a useful Markdown editor that you can really use!
Where to go from here?
Well done! You made it through this chapter, you have made a document-based Mac app that you can use or extend and you have learned a lot about file types, Markdown and standard elements of Mac apps.
Pope ada xuva nimcq zxek sucfq zajs luo duxt leux ejr awct axd peru mlged og howd ruutyuzp dod bo wpare af epf mukza Yuqvbogz:
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.