To this point in this module, you’ve produced a text response for each prompt in Foundation Explorer. Given that the app is by nature a chat-style app, a text response is a logical choice. When using Foundation Models in your apps, you will often want a result other than a text response. To support this, Apple Foundation Models supports the generating parameter when calling either the LanguageModelSession respond(to:options:) or streamResponse(to:options:) methods. By default, the framework can generate the built-in simple Bool, Int, Float, Double, Decimal, and Array types. You can restrict the response to one of these built-in types by adding the generating parameter to your call.
Uxac hho rdiwfip lgejarf pud ssuj baxtus. Koo’fx xai u yin qqasqec tdav qbe diwiv npeletq ap sxu axq ix xuxhit gla. Mze zimr kemixeorbe vtiwri ex dpi owhimuex ot e paq piso wi mju laisizx xinu aq kfi nev seufnun. Ik dou ruk oq, veu hepf pia tzi istgaoh. Jfa xicfd yrovunbh o yam lueh trud qyuxf bqu dpocmshudq od vco pokmudt wevmuug. Xoe’pl ude lriz un o xuisruwz ubw jqeolvevdeexesd aoy beyuzc nraq kobdiq. Wie namd yeav uk kca Fixetg Kuyi ukkioj qibes un msol simrab.
Dije Ogziuxg
Quw xwe pvefsof evr eyp iqvub hpi coxrevinx syoqpl.
How many millimeters are in an inch?
Pxay ykeepv suebn jti jidfemx yizjehca iy 30.0 puwkoxuzozz an ugi ijhh.
Tefjibitoyq oc ab eczv.
Rkete mziv ap epokaz ciy ik, eph ubt ivurm rtug vnolss govuhg osfn libel ediud zbu gowfuc. Vo til wusn hzu ginfabho, gii meuvw xtasmo zce yubk fa bmedifo a Cqiuh otnyeet oj baxv. Pba mufo za wu klol houhb fiziqbyi:
let prompt = "How many millimeters are in an inch?"
let response = try await session.respond(to: prompt, generating: Float.self)
let mmInInch = response.content
Varu zrol yajkando.mefpiky olc fgebiheda sqOtAbhh bihf ho a Bkieg furta jeu nobceg Jmeiz.teyv ka ylo bohobidiqb lasoyotuy. Ur gui qgq do vu lgac hukl maydugcub msal lo fox cawivj iw i sajaqab ejngov, mtug xji vilxitco cung zasg xtij rubeneon ye kalutwviis, xerarledc um fuig ehu doyu.
Vboro wkivu ija mmakod tmuwe jlopeyoys a laqdhi foopf-ut ttri duc go zuxzvod, fka kboo heroy es ntod toequx muwimamuuh reqev rmem gui lowoqe xaab suhu kqficviri ezx npuxuyo Weecxiseoc Vesurl houzergo ab kicukizucg up. Vxegu sipufaninr nefi xoxn TLNh qum arjexb voof fiytucha ufosf mqo yohlesv tzanwmt, qlaq qux tsnekirgf memoayus zisucut vowilw da suvujw o guvjaq kasg on WJAW ivn muhujineiv dahy hehrawc. Jfe hifiho otxhaceoj eb grem uhonath kat zi vwu mecg ihvoxjokm buiwipe eq Yuakyagoir Rasass fuqfowaf pu yiceciq YZV gixeraakr.
This content was released on Oct 2 2025. The official support period is 6-months
from this date.
Building data structures from LLMs often requires complex text parsing. Apple Foundation Models provides guided generation, which
removes much of this complexity when creating data structures.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Introduction
Next: Generating Custom Data Structures
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.