From 54ca43339d3e81dcecb07606755532dbe8bb3766 Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 7 Jan 2026 09:49:36 +0900 Subject: [PATCH 01/30] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C1=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - juhee.xcodeproj/project.pbxproj | 301 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 22185 bytes .../xcdebugger/Breakpoints_v2.xcbkptlist | 24 ++ .../xcschemes/xcschememanagement.plist | 14 + juhee/main.swift | 21 ++ 7 files changed, 367 insertions(+), 1 deletion(-) delete mode 100644 README.md create mode 100644 juhee.xcodeproj/project.pbxproj create mode 100644 juhee.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 juhee.xcodeproj/project.xcworkspace/xcuserdata/gimjuhui.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 juhee.xcodeproj/xcuserdata/gimjuhui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 juhee.xcodeproj/xcuserdata/gimjuhui.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 juhee/main.swift diff --git a/README.md b/README.md deleted file mode 100644 index af78fa5..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -## 내일배움캠프 2주차 과제입니다. diff --git a/juhee.xcodeproj/project.pbxproj b/juhee.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2d92c75 --- /dev/null +++ b/juhee.xcodeproj/project.pbxproj @@ -0,0 +1,301 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXCopyFilesBuildPhase section */ + B96062ED2F0CF71F0082C173 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + B96062EF2F0CF71F0082C173 /* juhee */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = juhee; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + B96062F12F0CF71F0082C173 /* juhee */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = juhee; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + B96062EC2F0CF71F0082C173 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B96062E62F0CF71F0082C173 = { + isa = PBXGroup; + children = ( + B96062F12F0CF71F0082C173 /* juhee */, + B96062F02F0CF71F0082C173 /* Products */, + ); + sourceTree = ""; + usesTabs = 0; + }; + B96062F02F0CF71F0082C173 /* Products */ = { + isa = PBXGroup; + children = ( + B96062EF2F0CF71F0082C173 /* juhee */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B96062EE2F0CF71F0082C173 /* juhee */ = { + isa = PBXNativeTarget; + buildConfigurationList = B96062F62F0CF71F0082C173 /* Build configuration list for PBXNativeTarget "juhee" */; + buildPhases = ( + B96062EB2F0CF71F0082C173 /* Sources */, + B96062EC2F0CF71F0082C173 /* Frameworks */, + B96062ED2F0CF71F0082C173 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + B96062F12F0CF71F0082C173 /* juhee */, + ); + name = juhee; + packageProductDependencies = ( + ); + productName = juhee; + productReference = B96062EF2F0CF71F0082C173 /* juhee */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B96062E72F0CF71F0082C173 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 2620; + LastUpgradeCheck = 2620; + TargetAttributes = { + B96062EE2F0CF71F0082C173 = { + CreatedOnToolsVersion = 26.2; + }; + }; + }; + buildConfigurationList = B96062EA2F0CF71F0082C173 /* Build configuration list for PBXProject "juhee" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B96062E62F0CF71F0082C173; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = B96062F02F0CF71F0082C173 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B96062EE2F0CF71F0082C173 /* juhee */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + B96062EB2F0CF71F0082C173 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B96062F42F0CF71F0082C173 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = YSBKYH9JX6; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 26.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B96062F52F0CF71F0082C173 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = YSBKYH9JX6; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 26.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + B96062F72F0CF71F0082C173 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = YSBKYH9JX6; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + B96062F82F0CF71F0082C173 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = YSBKYH9JX6; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B96062EA2F0CF71F0082C173 /* Build configuration list for PBXProject "juhee" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B96062F42F0CF71F0082C173 /* Debug */, + B96062F52F0CF71F0082C173 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B96062F62F0CF71F0082C173 /* Build configuration list for PBXNativeTarget "juhee" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B96062F72F0CF71F0082C173 /* Debug */, + B96062F82F0CF71F0082C173 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B96062E72F0CF71F0082C173 /* Project object */; +} diff --git a/juhee.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/juhee.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/juhee.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/juhee.xcodeproj/project.xcworkspace/xcuserdata/gimjuhui.xcuserdatad/UserInterfaceState.xcuserstate b/juhee.xcodeproj/project.xcworkspace/xcuserdata/gimjuhui.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..0687b24036d20ae5142b1de6f0a395e6d96269d2 GIT binary patch literal 22185 zcmeHvd3;kv*YM0;(n7a%OV`kpbZ^oo>6Vs4nAImY_?~QnVahfmWhx z(Jkm!bQ`)IZ9p5*CbSuCLEF$n=wY-S?L<$ZUFaF~JbDGaie5u|(LS^v9YbHCl|^M!IaEGXMj0s+RZdkH=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TFp95 zpJqUFzh;}}0nJ02r!~7Z&uE_0yr$W!*{6A5^M&Rc&5v42OKTaeL>sP+&_-&bwAI?_ z+6%NZv{vmr?e*HV+I8AK?SS?k?S0w@v=3>Y)9%&o)4rvBNBh1mPM4(9>h!uXx^X&# zZh~%-u1Z&{tJ5{ZlCTg-8;JXbsy@E>5l8Z)qSt~ zLHCpHlfuo?O zptoRk!J2{{1AKDwtDQ8vD3z`9lLStma$)sJu&v=xWsW8@In>(sxTgD?M6ztn};B?@CXU{#N>jAV&cT4iQ^~MPMj?I9~32iO5!}e Kn&)Gp<^KSo7nK + + + + + + + + diff --git a/juhee.xcodeproj/xcuserdata/gimjuhui.xcuserdatad/xcschemes/xcschememanagement.plist b/juhee.xcodeproj/xcuserdata/gimjuhui.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..c39169f --- /dev/null +++ b/juhee.xcodeproj/xcuserdata/gimjuhui.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + juhee.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/juhee/main.swift b/juhee/main.swift new file mode 100644 index 0000000..79b7eb5 --- /dev/null +++ b/juhee/main.swift @@ -0,0 +1,21 @@ +// +// main.swift +// juhee +// +// Created by 김주희 on 1/6/26. +// + +import Foundation + +// 과제 1 풀이 + +var sum: (Int, Int) -> String = { a, b in + return "두 수의 합은 \(a + b) 입니다." +} + +sum(10, 20) +print(sum) // 두 수의 합은 30 입니다. 출력 + +func calculate(a: Int, b: Int, closure: (Int, Int) -> String) -> Void { + closure(a, b) +} From dc2312fab3f8b5ded7ddcc1bd2c6dbaddadef138 Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 7 Jan 2026 16:57:03 +0900 Subject: [PATCH 02/30] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C2=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 햄드네요 --- juhee/main.swift | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/juhee/main.swift b/juhee/main.swift index 79b7eb5..d9b46c1 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -19,3 +19,38 @@ print(sum) // 두 수의 합은 30 입니다. 출력 func calculate(a: Int, b: Int, closure: (Int, Int) -> String) -> Void { closure(a, b) } + + + +// 과제 2 풀이 + +let numbers = [1, 2, 3, 4, 5] + +var result = [String]() + +result = numbers.map { String($0) } +print(result) + + +let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + +var result2 = numbers2.filter { $0 % 2 == 0} +var result3 = result2.map { String($0) } +print(result3) + + +func myMap (a: [Int], operation: (Int) -> String) -> [String] { + var result = [String]() + for i in a { + result.append(String(i)) + } + return result +} + +let result4 = myMap(a: [1, 2, 3, 4, 5]) { + String($0) +} + +print(result) + +// 과제 3 풀이 From e1afc8e1027037f0019a4e89ac9e53d6e344f0c8 Mon Sep 17 00:00:00 2001 From: coduhee Date: Thu, 8 Jan 2026 21:52:06 +0900 Subject: [PATCH 03/30] =?UTF-8?q?#=20=EA=B3=BC=EC=A0=9C1=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sum 정의하는것부터 잘못되어서 수정합니다.. --- juhee/main.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index d9b46c1..aa41a78 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -7,21 +7,19 @@ import Foundation -// 과제 1 풀이 +//과제 1 풀이 -var sum: (Int, Int) -> String = { a, b in +let sum = { (a: Int, b: Int) -> String in return "두 수의 합은 \(a + b) 입니다." } -sum(10, 20) -print(sum) // 두 수의 합은 30 입니다. 출력 +print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 func calculate(a: Int, b: Int, closure: (Int, Int) -> String) -> Void { - closure(a, b) + print(closure(a, b)) } - // 과제 2 풀이 let numbers = [1, 2, 3, 4, 5] @@ -34,8 +32,8 @@ print(result) let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -var result2 = numbers2.filter { $0 % 2 == 0} -var result3 = result2.map { String($0) } +let result2 = numbers2.filter { $0 % 2 == 0} +let result3 = result2.map { String($0) } print(result3) @@ -52,5 +50,3 @@ let result4 = myMap(a: [1, 2, 3, 4, 5]) { } print(result) - -// 과제 3 풀이 From fe65b99d49f4ed57b5410ec2da2711054ebb363d Mon Sep 17 00:00:00 2001 From: coduhee Date: Thu, 8 Jan 2026 22:39:43 +0900 Subject: [PATCH 04/30] =?UTF-8?q?#=20=EA=B3=BC=EC=A0=9C=202=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 체이닝 활용하는 부분, 함수의 매개변수로 클로저 사용하는 부분 수정하였습니다. --- juhee/main.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index aa41a78..4c5d68f 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -11,6 +11,7 @@ import Foundation let sum = { (a: Int, b: Int) -> String in return "두 수의 합은 \(a + b) 입니다." + // 클로저 타입 명시하는법? } print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 @@ -32,15 +33,15 @@ print(result) let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -let result2 = numbers2.filter { $0 % 2 == 0} -let result3 = result2.map { String($0) } -print(result3) +// 체이닝 방식으로 수정 +let result2 = numbers2.filter { $0 % 2 == 0} .map { String($0) } +print(result2) func myMap (a: [Int], operation: (Int) -> String) -> [String] { var result = [String]() for i in a { - result.append(String(i)) + result.append(operation(i)) // 파라미터로 받은 클로저 이용해서 변환 } return result } @@ -49,4 +50,4 @@ let result4 = myMap(a: [1, 2, 3, 4, 5]) { String($0) } -print(result) +print(result4) From 6037fb1285e931c57ea9f6a3b8c1b8c7b7f55f7a Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 10:45:29 +0900 Subject: [PATCH 05/30] =?UTF-8?q?=20#feat=20:=20=EB=AC=B8=EC=A0=9C3,4?= =?UTF-8?q?=EB=B2=88=20=ED=92=80=EC=9D=B4=20=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 180 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/juhee/main.swift b/juhee/main.swift index 4c5d68f..41c475a 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -51,3 +51,183 @@ let result4 = myMap(a: [1, 2, 3, 4, 5]) { } print(result4) + + + + +// 과제3 풀이 + +// 3-1 +func a (array: [Int]) -> [Int] { + + var returnArray = [Int]() + var count: Int = 0 + + for i in array { + count += 1 + if count % 2 != 0 { + returnArray.append(i) + } + } + return returnArray +} + +print(a(array: [1, 2, 3, 4, 5])) + + + +// 3-2 +func b (array: [String]) -> [String] { + + var returnArray = [String]() + var count: Int = 0 + + for i in array { + count += 1 + if count % 2 != 0 { + returnArray.append(i) + } + } + return returnArray +} + +print(b(array: ["가", "나", "다", "라", "마"])) + + +// 3-3 + +// 제네릭 +func c(array: [T]) ->[T] { + + var returnArray = [T]() + var count: Int = 0 + + for i in array { + count += 1 + if count % 2 != 0 { + returnArray.append(i) + } + } + return returnArray +} + +print(c(array: [1, 2, 3, 4, 5])) +print(c(array: ["가", "나", "다", "라", "마"])) + + + +// 3-4 +// 파라미터의 타입을 << 'Numeric 프로토콜'을 준수하는 타입의 요소를 가진 배열 >> 로 변경 +func d(array: [T]) ->[T] { + + var returnArray = [T]() + var count: Int = 0 + + for i in array { + count += 1 + if count % 2 != 0 { + returnArray.append(i) + } + } + return returnArray +} + +print(d(array: [1, 2, 3, 4, 5])) +// print(d(array: ["가", "나", "다", "라", "마"])) 오류 발생 + + + + +// 문제 4 풀이 + +protocol Introducible { + var name: String { get set } + + func introduce() -> String +} + + +class Robot: Introducible { + var name: String { + // 프로퍼티 옵져버 쓰기 + willSet { + if newValue != self.name { + print("변경 이전 값: \(self.name)") + print("변경 이후 값: \(newValue)") + self.name = newValue + } + } + } + + func introduce() -> String { + return "안녕하세요, 저는 \(name) 입니다." + } + + func batteryCharge() -> String { + return "전원을 충전합니다." + } + init(name: String) { + self.name = name + } +} + + + class Cat: Introducible { + var name: String + + func introduce() -> String { + return "안녕하세요, 저는 \(name) 입니다." + } + + func grooming() -> String { + return "야옹" + } + + init(name: String) { + self.name = name + } + } + + class Dog: Introducible { + var name: String + + func introduce() -> String { + return "안녕하세요, 저는 \(name) 입니다." + } + + func bark() -> String { + return "멍멍멍" + } + + init(name: String) { + self.name = name + } + } + + var robot = Robot(name: "로봇") + robot.name = "로봇 이름 변경" + + var cat = Cat(name: "냥이") + + var dog = Dog(name: "멈무") + + + +var arrayIntroducible = [Introducible]() + +arrayIntroducible.append(robot) +arrayIntroducible.append(cat) +arrayIntroducible.append(dog) + +for i in arrayIntroducible { + // i.batteryCharge() error: Value of type 'any Introducible' has no member 'batteryCharge' + if let robot = i as? Robot { + print(robot.batteryCharge()) + } + if let cat = i as? Cat { + print(cat.grooming()) + } + if let dog = i as? Dog { + print(dog.bark()) + } +} From 5e615329e5ef20e263afdb4ffbadcc8302affc66 Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 11:53:19 +0900 Subject: [PATCH 06/30] =?UTF-8?q?#=20=EA=B3=BC=EC=A0=9C=205=EB=B2=88=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/juhee/main.swift b/juhee/main.swift index 41c475a..f8fd997 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -231,3 +231,47 @@ for i in arrayIntroducible { print(dog.bark()) } } + + +// 문제 5 풀이 + +enum DeliveryStatus{ + case notStated + case inTransit(daysRemaining: Int) + case error +} + +enum DeliveryError: Error { + case invalidAddress + case notStarted + case systemError(reason: String) +} + +// throwing function +func predictDeliveryDay(for address: String, status: DeliveryStatus) throws -> String { + + if address.isEmpty { + throw DeliveryError.invalidAddress + } else { + switch status { + case .notStated: + throw DeliveryError.notStarted + case .error: + throw DeliveryError.systemError(reason: "알 수 없음") + case .inTransit(let daysRemaining): + return("배송까지 \(daysRemaining)일 남았습니다.") + } + } +} + +do { + let message = try predictDeliveryDay(for: "제주특별시", status: .inTransit(daysRemaining: 3)) + print(message) +} catch DeliveryError.invalidAddress { + print("주소가 잘못입력되었습니다. 주소를 확인해주세요.") +} catch DeliveryError.notStarted { + print("배송이 아직 시작되지 않았습니다.") +} catch DeliveryError.systemError(let reason) { + print("시스템 에러가 발생하였습니다: \(reason)") +} + From e0a4f289fa67c7f552d27028941379125b7273bd Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 12:32:05 +0900 Subject: [PATCH 07/30] =?UTF-8?q?refactor:=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20sum=20=ED=83=80=EC=9E=85=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index f8fd997..0845929 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -9,9 +9,9 @@ import Foundation //과제 1 풀이 -let sum = { (a: Int, b: Int) -> String in - return "두 수의 합은 \(a + b) 입니다." - // 클로저 타입 명시하는법? +// sum의 타입도 명시하고 클로저 내부 구현도 함 +let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String + in return "두 수의 합은 \(a + b) 입니다." } print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 From c08386559547a94b5893259e8b273b941c730182 Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 12:43:46 +0900 Subject: [PATCH 08/30] =?UTF-8?q?chore:=20->=20Void=20=EC=83=9D=EB=9E=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 함수의 출력값이 없을때 쓰는 -> Void는 생략이 가능하다. --- juhee/main.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 0845929..23d5d43 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -16,10 +16,10 @@ let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 -func calculate(a: Int, b: Int, closure: (Int, Int) -> String) -> Void { +func calculate(a: Int, b: Int, closure: (Int, Int) -> String) { print(closure(a, b)) } - +// 함수의 출력값이 없을때 -> Void 생략 가능 // 과제 2 풀이 From 23d5527046467fc67553bf733ac9afee2656b3a7 Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 14:19:43 +0900 Subject: [PATCH 09/30] =?UTF-8?q?chore:=20=EB=AC=B8=EC=A0=9C2=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=ED=83=80=EC=9E=85=EB=B3=80=EA=B2=BD,=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit result2 변수 var를 let으로 변경 체이닝 부분 줄바꿈으로 가독성 증가 --- juhee/main.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/juhee/main.swift b/juhee/main.swift index 23d5d43..3715ef6 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -35,7 +35,10 @@ let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // 체이닝 방식으로 수정 -let result2 = numbers2.filter { $0 % 2 == 0} .map { String($0) } +let result2 = numbers2 + .filter { $0 % 2 == 0} + .map { String($0) } // 줄바꿈 (수정), result2 배열 let으로 선언 (수정) + print(result2) func myMap (a: [Int], operation: (Int) -> String) -> [String] { From ab3797c6fd3bea5ae1bb24abc67fbfb7f5004027 Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 15:24:52 +0900 Subject: [PATCH 10/30] =?UTF-8?q?feat:=20=EC=A1=B0=EA=B1=B4=EB=AC=B8=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if count % 2 == 0 짝수배열일때 append하는것으로 코드 수정 --- juhee/main.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 3715ef6..3948ed0 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -68,7 +68,7 @@ func a (array: [Int]) -> [Int] { for i in array { count += 1 - if count % 2 != 0 { + if count % 2 == 0 { returnArray.append(i) } } @@ -87,7 +87,7 @@ func b (array: [String]) -> [String] { for i in array { count += 1 - if count % 2 != 0 { + if count % 2 == 0 { returnArray.append(i) } } @@ -107,7 +107,7 @@ func c(array: [T]) ->[T] { for i in array { count += 1 - if count % 2 != 0 { + if count % 2 == 0 { returnArray.append(i) } } From 353f33edf5dc4d8c334b7cedf9a4ec8486c6dc6c Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 16:06:22 +0900 Subject: [PATCH 11/30] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C4=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=86=A0=EC=BD=9C=EC=9D=98=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=8D=BC=ED=8B=B0=20=EC=A0=9C=EC=95=BD=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juhee/main.swift b/juhee/main.swift index 3948ed0..e6933ee 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -144,7 +144,7 @@ print(d(array: [1, 2, 3, 4, 5])) // 문제 4 풀이 protocol Introducible { - var name: String { get set } + var name: String { get } // 외부에서 이름을 변경해야한다는 조건은 없으므로 불필요한 제약조건이 생기는 get set에서 get 제약 조건으로 수정 func introduce() -> String } From ca48552de8d83195446d5c267812d9b2a07a4b63 Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 16:13:58 +0900 Subject: [PATCH 12/30] =?UTF-8?q?chore:=20=EB=93=A4=EC=97=AC=EC=93=B0?= =?UTF-8?q?=EA=B8=B0=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index e6933ee..8a84cfe 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -165,7 +165,7 @@ class Robot: Introducible { func introduce() -> String { return "안녕하세요, 저는 \(name) 입니다." } - + func batteryCharge() -> String { return "전원을 충전합니다." } @@ -175,44 +175,44 @@ class Robot: Introducible { } - class Cat: Introducible { - var name: String - - func introduce() -> String { - return "안녕하세요, 저는 \(name) 입니다." - } - - func grooming() -> String { - return "야옹" - } - - init(name: String) { - self.name = name - } +class Cat: Introducible { + var name: String + + func introduce() -> String { + return "안녕하세요, 저는 \(name) 입니다." } + + func grooming() -> String { + return "야옹" + } + + init(name: String) { + self.name = name + } +} - class Dog: Introducible { - var name: String - - func introduce() -> String { - return "안녕하세요, 저는 \(name) 입니다." - } - - func bark() -> String { - return "멍멍멍" - } - - init(name: String) { - self.name = name - } +class Dog: Introducible { + var name: String + + func introduce() -> String { + return "안녕하세요, 저는 \(name) 입니다." + } + + func bark() -> String { + return "멍멍멍" + } + + init(name: String) { + self.name = name } +} - var robot = Robot(name: "로봇") - robot.name = "로봇 이름 변경" +var robot = Robot(name: "로봇") +robot.name = "로봇 이름 변경" - var cat = Cat(name: "냥이") +var cat = Cat(name: "냥이") - var dog = Dog(name: "멈무") +var dog = Dog(name: "멈무") From 882f2ad566cb77e6aec3c13a304cac49bbe3eb9c Mon Sep 17 00:00:00 2001 From: coduhee Date: Fri, 9 Jan 2026 17:39:57 +0900 Subject: [PATCH 13/30] =?UTF-8?q?feat:=20willset=EB=AC=B8=EC=97=90=20?= =?UTF-8?q?=EC=9E=88=EB=8D=98=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EA=B0=92=20=EB=8C=80=EC=9E=85=EA=B3=BC=EC=A0=95=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 8a84cfe..f2edda7 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -144,7 +144,7 @@ print(d(array: [1, 2, 3, 4, 5])) // 문제 4 풀이 protocol Introducible { - var name: String { get } // 외부에서 이름을 변경해야한다는 조건은 없으므로 불필요한 제약조건이 생기는 get set에서 get 제약 조건으로 수정 + var name: String { get } func introduce() -> String } @@ -157,8 +157,7 @@ class Robot: Introducible { if newValue != self.name { print("변경 이전 값: \(self.name)") print("변경 이후 값: \(newValue)") - self.name = newValue - } + } // willset은 자동으로 값이 대입되므로 newValue = self.name 필요없음 (수정) } } From 3ac98fa9a7d615924645f79b6ec7fc1b50dcbf2c Mon Sep 17 00:00:00 2001 From: coduhee Date: Sat, 10 Jan 2026 12:59:42 +0900 Subject: [PATCH 14/30] =?UTF-8?q?chore:=20=EB=AC=B8=EC=A0=9C3=20=EB=B0=98?= =?UTF-8?q?=EB=B3=B5=EB=AC=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81,=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C4=20willSet=20self.=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제3번 반복문 활용 부분에서 .count를 사용하여 더 직관적이고 간결하게 코드를 작성하는 방향으로 리펙토링함. 문제4번 WillSet부분에서 self.name을 name으로 작성하여도 같은결과이므로 self. 삭제 --- juhee/main.swift | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index f2edda7..729c209 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -7,7 +7,7 @@ import Foundation -//과제 1 풀이 +// MARK: - 과제 1 풀이 // sum의 타입도 명시하고 클로저 내부 구현도 함 let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String @@ -21,7 +21,11 @@ func calculate(a: Int, b: Int, closure: (Int, Int) -> String) { } // 함수의 출력값이 없을때 -> Void 생략 가능 -// 과제 2 풀이 + + + + +// MARK: - 과제 2 풀이 let numbers = [1, 2, 3, 4, 5] @@ -58,43 +62,40 @@ print(result4) -// 과제3 풀이 +// MARK: - 과제3 풀이 // 3-1 func a (array: [Int]) -> [Int] { var returnArray = [Int]() - var count: Int = 0 - for i in array { - count += 1 - if count % 2 == 0 { - returnArray.append(i) + for i in 0.. [String] { var returnArray = [String]() - var count: Int = 0 - for i in array { - count += 1 - if count % 2 == 0 { - returnArray.append(i) + for i in 0.. Date: Sat, 10 Jan 2026 13:10:52 +0900 Subject: [PATCH 15/30] =?UTF-8?q?chore:=20=EB=AC=B8=EC=A0=9C=203=EB=B2=88?= =?UTF-8?q?=20=EB=B0=B0=EC=97=B4=20=EC=B6=94=EA=B0=80=20=EB=A6=AC=ED=8E=99?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 3번의 나머지 코드(제네릭, 프로토콜 추가)들도 같은 방식으로 수정함 --- juhee/main.swift | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 729c209..62edbb6 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -98,25 +98,23 @@ func b (array: [String]) -> [String] { print(b(array: ["가", "나", "다", "라", "마"])) // ["나", "라"] 출력 -// 3-3 +// 3-3 // 제네릭 func c(array: [T]) ->[T] { var returnArray = [T]() - var count: Int = 0 - for i in array { - count += 1 - if count % 2 == 0 { - returnArray.append(i) + for i in 0..(array: [T]) ->[T] { var returnArray = [T]() - var count: Int = 0 - for i in array { - count += 1 - if count % 2 != 0 { - returnArray.append(i) + for i in 0.. Date: Sat, 10 Jan 2026 21:41:43 +0900 Subject: [PATCH 16/30] =?UTF-8?q?chore:=20=EC=A3=BC=EC=84=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 62edbb6..92818a8 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -9,6 +9,7 @@ import Foundation // MARK: - 과제 1 풀이 +// 1-1 // sum의 타입도 명시하고 클로저 내부 구현도 함 let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String in return "두 수의 합은 \(a + b) 입니다." @@ -16,6 +17,7 @@ let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 +// 1-2 func calculate(a: Int, b: Int, closure: (Int, Int) -> String) { print(closure(a, b)) } @@ -24,27 +26,32 @@ func calculate(a: Int, b: Int, closure: (Int, Int) -> String) { - // MARK: - 과제 2 풀이 +// 2-1 let numbers = [1, 2, 3, 4, 5] var result = [String]() result = numbers.map { String($0) } -print(result) +print(result) // ["1", "2", "3", "4", "5"] 출력 -let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +// 2-2 +let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + // 체이닝 방식으로 수정 let result2 = numbers2 .filter { $0 % 2 == 0} .map { String($0) } // 줄바꿈 (수정), result2 배열 let으로 선언 (수정) -print(result2) +print(result2) // ["2", "4", "6", "8", "10"] 출력 + + +// 2-3 func myMap (a: [Int], operation: (Int) -> String) -> [String] { var result = [String]() for i in a { @@ -57,7 +64,7 @@ let result4 = myMap(a: [1, 2, 3, 4, 5]) { String($0) } -print(result4) +print(result4) // ["1", "2", "3", "4", "5"] 출력 @@ -140,6 +147,7 @@ print(d(array: [1, 2, 3, 4, 5])) // [2, 4] 출력 // MARK: - 문제 4 풀이 +// 4-1 protocol Introducible { var name: String { get } @@ -149,10 +157,11 @@ protocol Introducible { class Robot: Introducible { var name: String { - // 프로퍼티 옵져버 쓰기 + // 프로퍼티 옵져버 willSet { if newValue != name { - print("변경 이전 값: \(name)") + print("name 변경 알림") + print("변경 이전 값: \(name)") // self.name과 name은 같은 값임 print("변경 이후 값: \(newValue)") } // willset은 자동으로 값이 대입되므로 newValue = self.name 필요없음 (수정) } @@ -165,6 +174,7 @@ class Robot: Introducible { func batteryCharge() -> String { return "전원을 충전합니다." } + init(name: String) { self.name = name } @@ -187,6 +197,7 @@ class Cat: Introducible { } } + class Dog: Introducible { var name: String @@ -204,13 +215,14 @@ class Dog: Introducible { } var robot = Robot(name: "로봇") -robot.name = "로봇 이름 변경" +robot.name = "로봇" // willSet 출력문 실행 X +robot.name = "로봇 이름 변경" // name 변경 알림 변경 이전 값: 로봇 변경 이후 값: 로봇 이름 변경 출력 -var cat = Cat(name: "냥이") +// 4-2 +var cat = Cat(name: "냥이") var dog = Dog(name: "멈무") - var arrayIntroducible = [Introducible]() arrayIntroducible.append(robot) @@ -220,20 +232,19 @@ arrayIntroducible.append(dog) for i in arrayIntroducible { // i.batteryCharge() error: Value of type 'any Introducible' has no member 'batteryCharge' if let robot = i as? Robot { - print(robot.batteryCharge()) + print(robot.batteryCharge()) // 전원을 충전합니다. 출력 } if let cat = i as? Cat { - print(cat.grooming()) + print(cat.grooming()) // 야옹 출력 } if let dog = i as? Dog { - print(dog.bark()) + print(dog.bark()) // 멍멍멍 출력 } } - // MARK: - 문제 5 풀이 enum DeliveryStatus{ @@ -275,4 +286,3 @@ do { } catch DeliveryError.systemError(let reason) { print("시스템 에러가 발생하였습니다: \(reason)") } - From b9c03da97bf77be29ddec148a2bd2465944ae273 Mon Sep 17 00:00:00 2001 From: coduhee Date: Sat, 10 Jan 2026 22:29:54 +0900 Subject: [PATCH 17/30] Add README for Swift basic assignments This README provides an overview of the Swift basic assignments, covering key concepts such as closures, higher-order functions, generics, protocols, and error handling. --- README.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0538ddc --- /dev/null +++ b/README.md @@ -0,0 +1,98 @@ +# Swift 기초 과제 정리 + +이 프로젝트는 **Swift 기본 문법과 핵심 개념**을 학습하기 위한 과제 풀이를 정리한 코드입니다. +클로저, 고차함수, 제네릭, 프로토콜, 에러 처리 등 Swift의 주요 개념을 단계별로 구현했습니다. + +--- + +## 📁 프로젝트 구성 + +- `main.swift` + Swift Playground / Command Line Tool 환경에서 실행 가능한 단일 파일 + +--- + +## ✨ 과제 1: 클로저 (Closure) + +### 1-1. 클로저 타입 명시 +- `(Int, Int) -> String` 타입의 클로저 정의 +- 두 정수를 더한 결과를 문자열로 반환 + +### 1-2. 클로저를 파라미터로 받는 함수 +- 클로저를 매개변수로 받아 함수 내부에서 호출 + +--- + +## ✨ 과제 2: 고차함수 (map / filter) + +### 2-1. `map` 사용 +- Int 배열을 String 배열로 변환 + +### 2-2. 체이닝 방식 +- `filter` + `map`을 체이닝으로 사용 +- 짝수 요소만 추출 후 문자열로 변환 + +### 2-3. 커스텀 map 구현 +- 클로저를 파라미터로 받아 직접 `map` 기능 구현 + +--- + +## ✨ 과제 3: 제네릭 (Generic) + +### 3-1 / 3-2. 타입별 함수 구현 +- Int / String 배열에서 짝수 번째 요소 반환 + +### 3-3. 제네릭 함수 +- 배열의 타입과 관계없이 동일한 로직 처리 + +### 3-4. 제네릭 제약 +- `Numeric` 프로토콜을 준수하는 타입만 허용 + +--- + +## ✨ 과제 4: 프로토콜 & 타입 캐스팅 + +### Introducible 프로토콜 +- `name` 프로퍼티 (읽기 전용) +- `introduce()` 메서드 요구 + +### 구현 클래스 +- `Robot` (프로퍼티 옵저버 `willSet` 사용) +- `Cat` +- `Dog` + +### 핵심 개념 +- 프로토콜 타입 배열에 담으면 프로토콜에 정의된 멤버만 접근 가능 +- 구체 타입의 메서드는 다운캐스팅 후 사용 + +--- + +## ✨ 과제 5: 에러 처리 (throws) + +- enum과 associated value 활용 +- throwing 함수 정의 +- do–try–catch를 통한 에러 분기 처리 + +--- + +## 🧠 학습 포인트 + +- 클로저는 실행 로직을 값처럼 전달 +- 고차함수는 체이닝으로 가독성 향상 +- 제네릭은 타입에 의존하지 않는 공통 로직 작성 +- 프로토콜은 최소 요구사항을 정의 +- 에러 처리는 실패 원인을 명확하게 표현 + +--- + +## ▶️ 실행 방법 + +- Xcode Playground 또는 Command Line Tool 프로젝트에서 + `main.swift` 실행 + +--- + +## 🙋‍♀️ 작성자 + +- 김주희 +- 내일배움캠프 iOS 9기 '🤓왜_되는지_증명못함' 팀 From 391551a6bf19f6cd3b2c0fcaf2b779ee8aa79a87 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 10:58:27 +0900 Subject: [PATCH 18/30] =?UTF-8?q?feat:=20=EB=8F=84=EC=A0=84=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=202,3=EB=B2=88=20=ED=92=80=EC=9D=B4=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/juhee/main.swift b/juhee/main.swift index 92818a8..62bc1bc 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -286,3 +286,77 @@ do { } catch DeliveryError.systemError(let reason) { print("시스템 에러가 발생하였습니다: \(reason)") } + + + +// MARK: - 도전 문제 풀이 + + + +// 1-2 문제 + +// 제네릭 구조체 정의 +struct SortableBox { + var items: [T] +} + +// 타입 T가 Comparable을 준수할 때에만 sortItems() 메서드 확장 +extension SortableBox where T: Comparable { + mutating func sortItems() { // mutating 키워드 필수 + items.sort() + } +} + +// Comparable 따르는 타입 +var boxTypeA = SortableBox(items: [4, 10, 3]) +boxTypeA.sortItems() +print(boxTypeA.items) // [3, 4, 10] 정상 출력 + +// T가 Comparable이 아닌 구조체 사용 +struct BoxTypeB { + var i: Int +} + +var errorBox = SortableBox(items: [BoxTypeB(i: 7), BoxTypeB(i: 27)]) + +// errorBox.sortItems() +// 컴파일 에러: Referencing instance method 'sortItems()' on 'SortableBox' requires that 'BoxTypeB' conform to 'Comparable' + + + +// 1-3 문제 + +//protocol Introducible { +// var name: String { get } +// func introduce() -> String +//} +// +//extension Introducible { +// func introduce() -> String { // 기본 동작 제공 +// "안녕하세요. 제 이름은 \(name) 입니다." +// } +//} +// +//struct Robot: Introducible { +// let name: String +// +// func introduce() -> String { +// "저는 동물이 아닌 로봇 \(name)입니다." +// } +//} +// +//struct Cat: Introducible { +// let name: String +//} +// +//struct Dog: Introducible { +// let name: String +//} +// +//let robot = Robot(name: "쓱싹쓱싹 로봇 청소기") +//let cat = Cat(name: "아기고냥이") +//let dog = Dog(name: "모찌") +// +//print(robot.introduce()) // 저는 동물이 아닌 로봇 쓱싹쓱싹 로봇 청소기입니다. 출력 +//print(cat.introduce()) // 안녕하세요. 제 이름은 아기고냥이 입니다. +//print(dog.introduce()) // 안녕하세요. 제 이름은 모찌 입니다. From 8b7f901a92b62d39f01f2e45905c0a0ae3b54a59 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 11:14:09 +0900 Subject: [PATCH 19/30] Revise README for better organization and clarity Updated the README to enhance clarity and structure. --- README.md | 147 ++++++++++++++++++------------------------------------ 1 file changed, 49 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 0538ddc..600de77 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,49 @@ -# Swift 기초 과제 정리 - -이 프로젝트는 **Swift 기본 문법과 핵심 개념**을 학습하기 위한 과제 풀이를 정리한 코드입니다. -클로저, 고차함수, 제네릭, 프로토콜, 에러 처리 등 Swift의 주요 개념을 단계별로 구현했습니다. - ---- - -## 📁 프로젝트 구성 - -- `main.swift` - Swift Playground / Command Line Tool 환경에서 실행 가능한 단일 파일 - ---- - -## ✨ 과제 1: 클로저 (Closure) - -### 1-1. 클로저 타입 명시 -- `(Int, Int) -> String` 타입의 클로저 정의 -- 두 정수를 더한 결과를 문자열로 반환 - -### 1-2. 클로저를 파라미터로 받는 함수 -- 클로저를 매개변수로 받아 함수 내부에서 호출 - ---- - -## ✨ 과제 2: 고차함수 (map / filter) - -### 2-1. `map` 사용 -- Int 배열을 String 배열로 변환 - -### 2-2. 체이닝 방식 -- `filter` + `map`을 체이닝으로 사용 -- 짝수 요소만 추출 후 문자열로 변환 - -### 2-3. 커스텀 map 구현 -- 클로저를 파라미터로 받아 직접 `map` 기능 구현 - ---- - -## ✨ 과제 3: 제네릭 (Generic) - -### 3-1 / 3-2. 타입별 함수 구현 -- Int / String 배열에서 짝수 번째 요소 반환 - -### 3-3. 제네릭 함수 -- 배열의 타입과 관계없이 동일한 로직 처리 - -### 3-4. 제네릭 제약 -- `Numeric` 프로토콜을 준수하는 타입만 허용 - ---- - -## ✨ 과제 4: 프로토콜 & 타입 캐스팅 - -### Introducible 프로토콜 -- `name` 프로퍼티 (읽기 전용) -- `introduce()` 메서드 요구 - -### 구현 클래스 -- `Robot` (프로퍼티 옵저버 `willSet` 사용) -- `Cat` -- `Dog` - -### 핵심 개념 -- 프로토콜 타입 배열에 담으면 프로토콜에 정의된 멤버만 접근 가능 -- 구체 타입의 메서드는 다운캐스팅 후 사용 - ---- - -## ✨ 과제 5: 에러 처리 (throws) - -- enum과 associated value 활용 -- throwing 함수 정의 -- do–try–catch를 통한 에러 분기 처리 - ---- - -## 🧠 학습 포인트 - -- 클로저는 실행 로직을 값처럼 전달 -- 고차함수는 체이닝으로 가독성 향상 -- 제네릭은 타입에 의존하지 않는 공통 로직 작성 -- 프로토콜은 최소 요구사항을 정의 -- 에러 처리는 실패 원인을 명확하게 표현 - ---- - -## ▶️ 실행 방법 - -- Xcode Playground 또는 Command Line Tool 프로젝트에서 - `main.swift` 실행 - ---- - -## 🙋‍♀️ 작성자 - -- 김주희 -- 내일배움캠프 iOS 9기 '🤓왜_되는지_증명못함' 팀 +Swift 기초 과제 정리 +Swift 기본 문법을 연습하면서 작성한 과제 풀이 코드입니다. +클로저, 고차함수, 제네릭, 프로토콜, 에러 처리까지 한 번씩 직접 구현해봤습니다. + +프로젝트 구성 +main.swift +Playground / Command Line Tool 환경에서 실행 가능한 단일 파일 + +과제 1: 클로저 +(Int, Int) -> String 타입의 클로저 정의 +클로저를 파라미터로 받아 호출하는 함수 구현 + +과제 2: 고차함수 (map / filter) +map으로 타입 변환 +filter + map 체이닝 +클로저를 받아 동작하는 커스텀 map 구현 + +과제 3: 제네릭 +Int / String 배열에서 동일한 로직을 타입별로 구현 +제네릭으로 공통 로직 통합 +Numeric 제약을 걸어 특정 타입만 받도록 처리 + +과제 4: 프로토콜 & 타입 캐스팅 +Introducible 프로토콜 정의 (name, introduce()) +Robot / Cat / Dog 구현 +프로토콜 타입 배열에 담았을 때 접근 범위가 제한되는 것, 다운캐스팅이 필요한 상황을 확인 + +과제 5: 에러 처리 (throws) +enum + associated value로 에러 케이스 정의 +throwing 함수 구현 +do–try–catch로 상황별 분기 처리 + +도전 과제 2: 제네릭 제약 + 조건부 메서드 +SortableBox 제네릭 구조체 구현 (items: [T]) +T: Comparable일 때만 sortItems()가 보이도록 확장 +Comparable이 아닌 타입에선 sortItems() 호출 자체가 컴파일 단계에서 막히는 것까지 확인 + +도전 과제 3: 프로토콜 기본 구현 +Introducible에 기본 introduce() 동작을 extension으로 제공 +Cat, Dog는 introduce()를 직접 구현하지 않아도 기본 동작 사용 +Robot만 introduce() 별도 문장 출력 + +실행 방법 +Xcode Playground 또는 Command Line Tool 프로젝트에서 +main.swift 실행 + +작성자 +김주희 +내일배움캠프 iOS 9기 🤓왜_되는지_증명못함 팀 From 3b172e13542ef8821f5597038234c1b0b8fd03d0 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 11:15:29 +0900 Subject: [PATCH 20/30] Revise README for clarity and project organization Updated the README to enhance project structure and details. --- README.md | 139 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 600de77..707494a 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,90 @@ -Swift 기초 과제 정리 -Swift 기본 문법을 연습하면서 작성한 과제 풀이 코드입니다. -클로저, 고차함수, 제네릭, 프로토콜, 에러 처리까지 한 번씩 직접 구현해봤습니다. - -프로젝트 구성 -main.swift -Playground / Command Line Tool 환경에서 실행 가능한 단일 파일 - -과제 1: 클로저 -(Int, Int) -> String 타입의 클로저 정의 -클로저를 파라미터로 받아 호출하는 함수 구현 - -과제 2: 고차함수 (map / filter) -map으로 타입 변환 -filter + map 체이닝 -클로저를 받아 동작하는 커스텀 map 구현 - -과제 3: 제네릭 -Int / String 배열에서 동일한 로직을 타입별로 구현 -제네릭으로 공통 로직 통합 -Numeric 제약을 걸어 특정 타입만 받도록 처리 - -과제 4: 프로토콜 & 타입 캐스팅 -Introducible 프로토콜 정의 (name, introduce()) -Robot / Cat / Dog 구현 -프로토콜 타입 배열에 담았을 때 접근 범위가 제한되는 것, 다운캐스팅이 필요한 상황을 확인 - -과제 5: 에러 처리 (throws) -enum + associated value로 에러 케이스 정의 -throwing 함수 구현 -do–try–catch로 상황별 분기 처리 - -도전 과제 2: 제네릭 제약 + 조건부 메서드 -SortableBox 제네릭 구조체 구현 (items: [T]) -T: Comparable일 때만 sortItems()가 보이도록 확장 -Comparable이 아닌 타입에선 sortItems() 호출 자체가 컴파일 단계에서 막히는 것까지 확인 - -도전 과제 3: 프로토콜 기본 구현 -Introducible에 기본 introduce() 동작을 extension으로 제공 -Cat, Dog는 introduce()를 직접 구현하지 않아도 기본 동작 사용 -Robot만 introduce() 별도 문장 출력 - -실행 방법 -Xcode Playground 또는 Command Line Tool 프로젝트에서 -main.swift 실행 - -작성자 -김주희 -내일배움캠프 iOS 9기 🤓왜_되는지_증명못함 팀 +# Swift 기초 과제 정리 + +Swift 기본 문법을 연습하면서 작성한 과제 풀이 코드입니다. +클로저, 고차함수, 제네릭, 프로토콜, 에러 처리까지 직접 구현해봤습니다. + +--- + +## 📁 프로젝트 구성 + +- `main.swift` + Playground / Command Line Tool 환경에서 실행 가능한 단일 파일 + +--- + +## ✅ 과제 1: 클로저 (Closure) + +- `(Int, Int) -> String` 타입의 클로저 정의 +- 클로저를 파라미터로 받아 호출하는 함수 구현 + +--- + +## ✅ 과제 2: 고차함수 (map / filter) + +- `map`으로 타입 변환 +- `filter` + `map` 체이닝 +- 클로저를 받아 동작하는 커스텀 `map` 구현 + +--- + +## ✅ 과제 3: 제네릭 (Generic) + +- Int / String 배열에서 동일한 로직을 타입별로 구현 +- 제네릭으로 공통 로직 통합 +- `Numeric` 제약을 걸어 특정 타입만 받도록 처리 + +--- + +## ✅ 과제 4: 프로토콜 & 타입 캐스팅 + +### Introducible 프로토콜 + +- `name` 프로퍼티 (읽기 전용) +- `introduce()` 메서드 요구 + +### 구현 타입 + +- `Robot / Cat / Dog` + +### 확인한 내용 + +- 프로토콜 타입 배열에 담으면 프로토콜에 정의된 멤버만 접근 가능 +- 구체 타입의 기능은 다운캐스팅 후 사용 가능 + +--- + +## ✅ 과제 5: 에러 처리 (throws) + +- enum + associated value로 에러 케이스 정의 +- throwing 함수 구현 +- do–try–catch로 상황별 분기 처리 + +--- + +## 🚀 도전 과제 2: 제네릭 제약 + 조건부 메서드 + +- `SortableBox` 제네릭 구조체 구현 (`items: [T]`) +- `T: Comparable`일 때만 `sortItems()`가 보이도록 확장 +- Comparable이 아닌 타입은 `sortItems()` 호출 시 컴파일 오류로 막히는 것 확인 + +--- + +## 🚀 도전 과제 3: 프로토콜 기본 구현 + +- `Introducible` extension에서 기본 `introduce()` 제공 +- `Cat`, `Dog`는 `introduce()` 구현 없이 기본 동작 사용 +- `Robot`은 기본 동작 대신 커스텀 `introduce()` 구현 + +--- + +## ▶️ 실행 방법 + +- Xcode Playground 또는 Command Line Tool 프로젝트에서 + `main.swift` 실행 + +--- + +## 🙋‍♀️ 작성자 + +- 김주희 +- 내일배움캠프 iOS 9기 `🤓왜_되는지_증명못함` 팀 From 05daeb449e17e8a5dbf5c8f009b75a770c1fb228 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 11:47:03 +0900 Subject: [PATCH 21/30] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 707494a..27fe470 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Swift 기초 과제 정리 +# Swift 과제 정리 Swift 기본 문법을 연습하면서 작성한 과제 풀이 코드입니다. 클로저, 고차함수, 제네릭, 프로토콜, 에러 처리까지 직접 구현해봤습니다. @@ -39,7 +39,7 @@ Swift 기본 문법을 연습하면서 작성한 과제 풀이 코드입니다. ### Introducible 프로토콜 -- `name` 프로퍼티 (읽기 전용) +- `name` 프로퍼티 - `introduce()` 메서드 요구 ### 구현 타입 From 7868876d728e976543141620780807686a7ca526 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 19:09:53 +0900 Subject: [PATCH 22/30] =?UTF-8?q?feat:=20return=20=EC=83=9D=EB=9E=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juhee/main.swift b/juhee/main.swift index 62bc1bc..67275f7 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -12,7 +12,7 @@ import Foundation // 1-1 // sum의 타입도 명시하고 클로저 내부 구현도 함 let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String - in return "두 수의 합은 \(a + b) 입니다." + in "두 수의 합은 \(a + b) 입니다." // return 생략 } print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 From e834ba7f315407f8e9dcadc3cc61637d1764e676 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 19:19:47 +0900 Subject: [PATCH 23/30] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C3=20=EB=A6=AC?= =?UTF-8?q?=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3-1, 3-2문제를 .enumerated() 를 이용한 풀이로 리펙토링 3-3, 3-4문제는 기존 코드에서 [1, 3, 5], ["가", "다", "마"] 출력되도록 조건문 수정 --- juhee/main.swift | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 67275f7..11b434f 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -72,37 +72,35 @@ print(result4) // ["1", "2", "3", "4", "5"] 출력 // MARK: - 과제3 풀이 // 3-1 -func a (array: [Int]) -> [Int] { - - var returnArray = [Int]() - - for i in 0.. [Int] { + array.enumerated() // [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)] + .filter { (idx, _) in // 튜플에서 인덱스만 보고 2의 배수인것만 남긴다 + idx.isMultiple(of: 2) // [(0, 1), (2, 3), (4, 5)]만 필터링 되어서 남음 } - } - return returnArray + .map { (_, value) in // 튜플에서 value값만 뽑아서 배열로 만듬 + value + } + // [1, 3, 5] } -print(a(array: [1, 2, 3, 4, 5])) // [2, 4] 출력 +print(a([1, 2, 3, 4, 5])) // [1, 3, 5] 출력 // 3-2 // 3-1번 풀이와 매개변수의 타입만 다를뿐 풀이 방식은 같음 func b (array: [String]) -> [String] { - - var returnArray = [String]() - - for i in 0..(array: [T]) ->[T] { var returnArray = [T]() - for i in 0..(array: [T]) ->[T] { return returnArray } -print(c(array: [1, 2, 3, 4, 5])) // 2, 4 출력 -print(c(array: ["가", "나", "다", "라", "마"])) // ["나", "라"] 출력 +print(c(array: [1, 2, 3, 4, 5])) // [1, 3, 5] 출력 +print(c(array: ["가", "나", "다", "라", "마"])) // ["가", "다", "마"] 출력 @@ -131,15 +129,15 @@ func d(array: [T]) ->[T] { var returnArray = [T]() - for i in 0.. Date: Mon, 12 Jan 2026 19:23:57 +0900 Subject: [PATCH 24/30] =?UTF-8?q?#=20feat:=20=EB=AC=B8=EC=A0=9C=204?= =?UTF-8?q?=EB=B2=88=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 배열을 선언과 동시에 초기화하도록 수정, if else 중첩문을 guard로 수정 --- juhee/main.swift | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 11b434f..3567b32 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -221,11 +221,7 @@ robot.name = "로봇 이름 변경" // name 변경 알림 변경 이전 값: var cat = Cat(name: "냥이") var dog = Dog(name: "멈무") -var arrayIntroducible = [Introducible]() - -arrayIntroducible.append(robot) -arrayIntroducible.append(cat) -arrayIntroducible.append(dog) +let arrayIntroducible: [Introducible] = [robot, cat, dog] // 선언과 동시에 초기화 하도록 리펙토링 for i in arrayIntroducible { // i.batteryCharge() error: Value of type 'any Introducible' has no member 'batteryCharge' @@ -260,17 +256,16 @@ enum DeliveryError: Error { // throwing function func predictDeliveryDay(for address: String, status: DeliveryStatus) throws -> String { - if address.isEmpty { + guard !address.isEmpty else { // if else 중첩문에서 guard로 리펙토링 throw DeliveryError.invalidAddress - } else { - switch status { - case .notStated: - throw DeliveryError.notStarted - case .error: - throw DeliveryError.systemError(reason: "알 수 없음") - case .inTransit(let daysRemaining): - return("배송까지 \(daysRemaining)일 남았습니다.") - } + } + switch status { + case .notStated: + throw DeliveryError.notStarted + case .error: + throw DeliveryError.systemError(reason: "알 수 없음") + case .inTransit(let daysRemaining): + return("배송까지 \(daysRemaining)일 남았습니다.") } } From 3d58f8fcff900b5edc2961c735a183bbb4db802b Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 20:00:13 +0900 Subject: [PATCH 25/30] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C4=20=EB=A6=AC?= =?UTF-8?q?=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if문 나열한것을 else if문으로 수정하여 비효율적인 반복문 실행을 줄이고 가독성을 향상함 --- juhee/main.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 3567b32..37d82c0 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -223,16 +223,14 @@ var dog = Dog(name: "멈무") let arrayIntroducible: [Introducible] = [robot, cat, dog] // 선언과 동시에 초기화 하도록 리펙토링 -for i in arrayIntroducible { +arrayIntroducible.forEach { // i.batteryCharge() error: Value of type 'any Introducible' has no member 'batteryCharge' - if let robot = i as? Robot { - print(robot.batteryCharge()) // 전원을 충전합니다. 출력 - } - if let cat = i as? Cat { - print(cat.grooming()) // 야옹 출력 - } - if let dog = i as? Dog { - print(dog.bark()) // 멍멍멍 출력 + if let robot = $0 as? Robot { // 비효율적인 반복을 줄이고 가독성 향상을 위해 else if문으로 수정 + print(robot.batteryCharge()) + } else if let cat = $0 as? Cat { + print(cat.grooming()) + } else if let dog = $0 as? Dog { + print(dog.bark()) } } From a8aa22bc7e9bac71d8d69edfcd2a4c42c1d11cb5 Mon Sep 17 00:00:00 2001 From: coduhee Date: Mon, 12 Jan 2026 20:13:57 +0900 Subject: [PATCH 26/30] =?UTF-8?q?#=20chore:=20=EB=8F=84=EC=A0=84=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=202=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 변수 이름 수정해 가독성 향상 --- juhee/main.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 37d82c0..ab76bbf 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -299,18 +299,18 @@ extension SortableBox where T: Comparable { } // Comparable 따르는 타입 -var boxTypeA = SortableBox(items: [4, 10, 3]) -boxTypeA.sortItems() -print(boxTypeA.items) // [3, 4, 10] 정상 출력 +var intBox = SortableBox(items: [4, 10, 3]) // 변수이름의 의미가 명확히 드러나게 수정 (intBox) +intBox.sortItems() +print(intBox.items) // [3, 4, 10] 정상 출력 // T가 Comparable이 아닌 구조체 사용 struct BoxTypeB { var i: Int } -var errorBox = SortableBox(items: [BoxTypeB(i: 7), BoxTypeB(i: 27)]) +var nonComparableBox = SortableBox(items: [BoxTypeB(i: 7), BoxTypeB(i: 27)]) // 변수 이름 수정 (가독성) -// errorBox.sortItems() +// nonComparableBox.sortItems() // 컴파일 에러: Referencing instance method 'sortItems()' on 'SortableBox' requires that 'BoxTypeB' conform to 'Comparable' From a40866dad403a0008b564167b6a129e8fb51911f Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 14 Jan 2026 19:47:28 +0900 Subject: [PATCH 27/30] =?UTF-8?q?refactor:=20=ED=83=80=EC=9E=85=EC=B6=94?= =?UTF-8?q?=EB=A1=A0=20=EA=B8=B0=EB=8A=A5=20=EC=9D=B4=EC=9A=A9=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B0=84=EA=B2=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index ab76bbf..aa114be 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -11,9 +11,8 @@ import Foundation // 1-1 // sum의 타입도 명시하고 클로저 내부 구현도 함 -let sum: (Int, Int) -> String = {(a: Int, b: Int) -> String - in "두 수의 합은 \(a + b) 입니다." // return 생략 -} +// 타입 추론 기능을 이용해 간결하게 리펙토링 +let sum: (Int, Int) -> String = { "두 수의 합은 \(a + b) 입니다." } // return 생략 print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 From 31bd9757f1e31edfbfc3836ab229976e98f892da Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 14 Jan 2026 19:48:20 +0900 Subject: [PATCH 28/30] =?UTF-8?q?refactor:=20=EC=98=A4=ED=83=88=EC=9E=90?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juhee/main.swift b/juhee/main.swift index aa114be..b6a332a 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -12,7 +12,7 @@ import Foundation // 1-1 // sum의 타입도 명시하고 클로저 내부 구현도 함 // 타입 추론 기능을 이용해 간결하게 리펙토링 -let sum: (Int, Int) -> String = { "두 수의 합은 \(a + b) 입니다." } // return 생략 +let sum: (Int, Int) -> String = { "두 수의 합은 \($0 + $1) 입니다." } // return 생략 print(sum(10, 20)) // 두 수의 합은 30 입니다. 출력 From fb8f3dc3b4477e9f18b6b2552e850be1ea46d5cb Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 14 Jan 2026 19:59:06 +0900 Subject: [PATCH 29/30] =?UTF-8?q?refactor:=20=EC=9A=A9=EB=8F=84=EC=97=90?= =?UTF-8?q?=20=EB=A7=9E=EA=B2=8C=20willSet=20->=20didSet=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index b6a332a..4cf2933 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -155,12 +155,12 @@ protocol Introducible { class Robot: Introducible { var name: String { // 프로퍼티 옵져버 - willSet { - if newValue != name { + didSet { // 값이 변경되었음을 알릴때는 willSet보다 didSet이 적합함 + if oldValue != name { print("name 변경 알림") - print("변경 이전 값: \(name)") // self.name과 name은 같은 값임 - print("변경 이후 값: \(newValue)") - } // willset은 자동으로 값이 대입되므로 newValue = self.name 필요없음 (수정) + print("변경 이전 값: \(oldValue)") + print("변경 이후 값: \(name)") + } } } From b8077af128e46883a507fa5df47647615387fec7 Mon Sep 17 00:00:00 2001 From: coduhee Date: Wed, 14 Jan 2026 20:35:40 +0900 Subject: [PATCH 30/30] =?UTF-8?q?refactor:=20=EC=98=A4=ED=83=88=EC=9E=90?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- juhee/main.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/juhee/main.swift b/juhee/main.swift index 4cf2933..e58ba86 100644 --- a/juhee/main.swift +++ b/juhee/main.swift @@ -239,7 +239,7 @@ arrayIntroducible.forEach { // MARK: - 문제 5 풀이 enum DeliveryStatus{ - case notStated + case notStarted case inTransit(daysRemaining: Int) case error } @@ -257,7 +257,7 @@ func predictDeliveryDay(for address: String, status: DeliveryStatus) throws -> S throw DeliveryError.invalidAddress } switch status { - case .notStated: + case .notStarted: throw DeliveryError.notStarted case .error: throw DeliveryError.systemError(reason: "알 수 없음")