{"id":4107,"date":"2026-01-21T19:08:33","date_gmt":"2026-01-21T10:08:33","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=4107"},"modified":"2026-01-21T19:41:06","modified_gmt":"2026-01-21T10:41:06","slug":"swift-function-label","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2026\/01\/21\/swift-function-label\/","title":{"rendered":"[swift] \ud568\uc218 \ub808\uc774\ube14\/Function label"},"content":{"rendered":"\n<p>\ud83d\udc49\ud83c\udffb \ud568\uc218\ub808\uc774\ube14 \/ Function label<\/p>\n\n\n\n<p>\u2714\ufe0f \uc2a4\uc704\ud504\ud2b8\uc5d0\uc11c\ub294 \ud30c\ub77c\uba54\ud130 \uc678\uc5d0 \ud568\uc218\ub808\uc774\ube14\uc744 \uc0ac\uc6a9 \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>In Swift, you can use function labels in addition to parameters.<\/p>\n\n\n\n<p>\u2714\ufe0f \ud568\uc218\ub808\uc774\ube14\uc740 \ucf54\ub4dc\uc758 \uac00\ub3c5\uc131\uc744 \ub192\uc774\uae30 \uc704\ud574\uc11c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<br>Function labels are used to improve the readability of code.<\/p>\n\n\n\n<p>\u2714\ufe0f \ubc14\ub85c \uc544\ub798\uc758 \ucf54\ub4dc\ucc98\ub7fc to\uc640 for\uac00 \ub808\uc774\ube14\uc774 \ub429\ub2c8\ub2e4.<br>As in the code below, to and for become labels.<\/p>\n\n\n\n<p>\u2714\ufe0f \ud568\uc218\ub0b4\ubd80\uc5d0\uc11c \uc0ac\uc6a9\uc2dc\ub294 \ud30c\ub77c\uba54\ud130\ub97c \uc0ac\uc6a9\ud558\uace0 \uc678\ubd80\uc5d0\uc11c\ub294 \ub808\uc774\ube14\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>When used inside a function, you can use parameters, and when used outside, you can use labels.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    func welcome(to town: String, for guest: String) -> String {\n        let fulltown = \"\\(town)\uc5d0 \uc624\uc2e0 \uac83\uc744 \ud658\uc601\ud569\ub2c8\ub2e4, \\(guest)\ub2d8!\\nWelcome to \\(town), \\(guest)!\"\n        return fulltown\n    }<\/code><\/pre>\n\n\n\n<p>\u2714\ufe0f \uc678\ubd80\uc5d0\uc11c \ub808\uc774\ube14\uc744 \uc544\ub798\ucc98\ub7fc \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<br>Use labels externally like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>            Button(\"\uc9c0\uc5ed \ud658\uc601 \uc778\uc0ac\/Local welcome greetings\") {\n                message = welcome(to: \"Night City\", for: \"Johnny Silver Hand\")\n            }<\/code><\/pre>\n\n\n\n<p>\u2714\ufe0f \uc640\uc77c\ub4dc \uce74\ub4dc( _ )\ub97c \uc0ac\uc6a9\ud558\uba74 \ub808\uc774\ube14\uc744 \uc0dd\ub7b5 \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>You can omit labels by using the wildcard ( _ ).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    func addExclamation(_ textmsg: String) -> String {\n        let textmessage = \"\\(textmsg) + !!!@@\"\n        return textmessage\n    }<\/code><\/pre>\n\n\n\n<p>\u2714\ufe0f \uc544\ub798\uc758 \ucf54\ub4dc\ub294 \uac00\uc7a5 \uc77c\ubc18\uc801\uc778 \ud568\uc218\uc758 \ud615\ud0dc\ub85c \ud30c\ub77c\uba54\ud130\uc640 \ub808\uc774\ube14\uc744 \uac19\uc774 \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0 \uc785\ub2c8\ub2e4.<br>The code below uses parameters and labels together in the most common function form.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    func greet(name: String) -> String {\n        let fullname = \"Hello, \\(name)!\"\n        return fullname\n    }<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \uc804\uccb4 \ucf54\ub4dc \/ Full Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nimport SwiftUI\n\nstruct ContentView: View {\n    @State private var message: String = \"\ubc84\ud2bc\uc744 \ub20c\ub7ec\ubcf4\uc138\uc694\/Try pressing the button\"\n\n    \/\/ \ub808\uc774\ube14\uacfc \ud30c\ub77c\ubbf8\ud130 \uc774\ub984\uc744 \ud1b5\uc77c\ud55c \uacbd\uc6b0 (\uac00\uc7a5 \uc77c\ubc18\uc801)\n    \/\/ When labels and parameter names are unified (most common)\n    func greet(name: String) -> String {\n        let fullname = \"Hello, \\(name)!\"\n        return fullname\n    }\n\n    \/\/ \uc544\uaddc\uba3c\ud2b8(\ud30c\ub77c\uba54\ud130) \ub808\uc774\ube14\uc744 \ub530\ub85c \uc368\uc11c \ubb38\uc7a5\ucc98\ub7fc \ub9cc\ub4e0 \uacbd\uc6b0 (\uac00\ub3d9\uc131 \uc911\uc2ec)\n    \/\/ When creating a sentence by writing argument (parameter) labels separately (focused on mobility)\n    func welcome(to town: String, for guest: String) -> String {\n        let fulltown = \"\\(town)\uc5d0 \uc624\uc2e0 \uac83\uc744 \ud658\uc601\ud569\ub2c8\ub2e4, \\(guest)\ub2d8!\\nWelcome to \\(town), \\(guest)!\"\n        return fulltown\n    }\n\n    \/\/ \uc640\uc77c\ub4dc\uce74\ub4dc(_)\ub97c \uc0ac\uc6a9\ud574 \ub808\uc774\ube14\uc744 \uc0dd\ub7b5\ud55c \uacbd\uc6b0 (\uac04\uacb0\ud568 \uc911\uc2ec)\n    \/\/ If the label is omitted using a wildcard (_) (focused on brevity)\n    func addExclamation(_ textmsg: String) -> String {\n        let textmessage = \"\\(textmsg) + !!!@@\"\n        return textmessage\n    }\n\n    var body: some View {\n        VStack(spacing: 20) {\n            Text(message)\n                .font(.headline)\n                .padding()\n\n            \/\/ \uc77c\ubc18\uc801\uc778 \ud615\ud0dc\n            \/\/ common form\n            Button(\"\uc774\ub984\uc73c\ub85c\uc778\uc0ac\/greetings by name\") {\n                message = greet(name: \"Cyberpunk2077\")\n            }\n\n            \/\/ to, for \ub808\uc774\ube14 \uc0ac\uc6a9\n            \/\/ Use to, for labels\n            Button(\"\uc9c0\uc5ed \ud658\uc601 \uc778\uc0ac\/Local welcome greetings\") {\n                message = welcome(to: \"Night City\", for: \"Johnny Silver Hand\")\n            }\n            \n            \/\/ \uc544\ub798\uc758 \ucf54\ub4dc\ub294 \uc624\ub958 \ubc1c\uc0dd\n\/\/            Button(\"\uc9c0\uc5ed \ud658\uc601 \uc778\uc0ac\") {\n\/\/                message = welcome(town: \"\uc11c\uc6b8\", guest: \"\ucca0\uc218\")\n\/\/            }\n\n            \/\/ \ub808\uc774\ube14 \uc0dd\ub7b5\n            \/\/ Label omitted\n            Button(\"Success\") {\n                message = addExclamation(\"Success\")\n            }\n        }\n    }\n}\n\n#Preview {\n    ContentView()\n}<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \uc2a4\ud06c\ub9b0 \uc0f7 \/ ScreenShot<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"1024\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/01\/funcLabel-468x1024.png\" alt=\"\" class=\"wp-image-4111\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/01\/funcLabel-468x1024.png 468w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/01\/funcLabel-137x300.png 137w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/01\/funcLabel-400x875.png 400w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/01\/funcLabel.png 470w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udc49\ud83c\udffb \ud568\uc218\ub808\uc774\ube14 \/ Function label \u2714\ufe0f \uc2a4\uc704\ud504\ud2b8\uc5d0\uc11c\ub294 \ud30c\ub77c\uba54\ud130 \uc678\uc5d0 \ud568\uc218\ub808\uc774\ube14\uc744 \uc0ac\uc6a9 \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.In Swift, you can use function labels in addition to parameters. \u2714\ufe0f \ud568\uc218\ub808\uc774\ube14\uc740 \ucf54\ub4dc\uc758 \uac00\ub3c5\uc131\uc744 \ub192\uc774\uae30 \uc704\ud574\uc11c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.Function labels are used to improve the readability of code. \u2714\ufe0f \ubc14\ub85c \uc544\ub798\uc758 \ucf54\ub4dc\ucc98\ub7fc to\uc640 for\uac00 \ub808\uc774\ube14\uc774 \ub429\ub2c8\ub2e4.As in the code below, to and for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,1],"tags":[],"class_list":["post-4107","post","type-post","status-publish","format-standard","hentry","category-swift","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/4107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=4107"}],"version-history":[{"count":10,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/4107\/revisions"}],"predecessor-version":[{"id":4119,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/4107\/revisions\/4119"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=4107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=4107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=4107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}