diff --git a/Combine-Study/Combine-Study.xcodeproj/project.pbxproj b/Combine-Study/Combine-Study.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2178811 --- /dev/null +++ b/Combine-Study/Combine-Study.xcodeproj/project.pbxproj @@ -0,0 +1,372 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 8DB089532EF1D06900042BCA /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8DB089522EF1D06900042BCA /* SnapKit */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 8DB0889E2EF1C39200042BCA /* Combine-Study.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Combine-Study.app"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 8DB088B02EF1C39400042BCA /* Exceptions for "Combine-Study" folder in "Combine-Study" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = 8DB0889D2EF1C39200042BCA /* Combine-Study */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 8DB088A02EF1C39200042BCA /* Combine-Study */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 8DB088B02EF1C39400042BCA /* Exceptions for "Combine-Study" folder in "Combine-Study" target */, + ); + path = "Combine-Study"; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8DB0889B2EF1C39200042BCA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8DB089532EF1D06900042BCA /* SnapKit in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8DB088952EF1C39200042BCA = { + isa = PBXGroup; + children = ( + 8DB088A02EF1C39200042BCA /* Combine-Study */, + 8DB0889F2EF1C39200042BCA /* Products */, + ); + sourceTree = ""; + }; + 8DB0889F2EF1C39200042BCA /* Products */ = { + isa = PBXGroup; + children = ( + 8DB0889E2EF1C39200042BCA /* Combine-Study.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8DB0889D2EF1C39200042BCA /* Combine-Study */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8DB088B12EF1C39400042BCA /* Build configuration list for PBXNativeTarget "Combine-Study" */; + buildPhases = ( + 8DB0889A2EF1C39200042BCA /* Sources */, + 8DB0889B2EF1C39200042BCA /* Frameworks */, + 8DB0889C2EF1C39200042BCA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 8DB088A02EF1C39200042BCA /* Combine-Study */, + ); + name = "Combine-Study"; + packageProductDependencies = ( + 8DB089522EF1D06900042BCA /* SnapKit */, + ); + productName = "Combine-Study"; + productReference = 8DB0889E2EF1C39200042BCA /* Combine-Study.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8DB088962EF1C39200042BCA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 2600; + LastUpgradeCheck = 2600; + TargetAttributes = { + 8DB0889D2EF1C39200042BCA = { + CreatedOnToolsVersion = 26.0.1; + }; + }; + }; + buildConfigurationList = 8DB088992EF1C39200042BCA /* Build configuration list for PBXProject "Combine-Study" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8DB088952EF1C39200042BCA; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + 8DB089512EF1D06900042BCA /* XCRemoteSwiftPackageReference "SnapKit" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = 8DB0889F2EF1C39200042BCA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8DB0889D2EF1C39200042BCA /* Combine-Study */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8DB0889C2EF1C39200042BCA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8DB0889A2EF1C39200042BCA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 8DB088B22EF1C39400042BCA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Combine-Study/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "sangsoo.Combine-Study"; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 8DB088B32EF1C39400042BCA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Combine-Study/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "sangsoo.Combine-Study"; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 8DB088B42EF1C39400042BCA /* 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; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 8DB088B52EF1C39400042BCA /* 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"; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8DB088992EF1C39200042BCA /* Build configuration list for PBXProject "Combine-Study" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8DB088B42EF1C39400042BCA /* Debug */, + 8DB088B52EF1C39400042BCA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8DB088B12EF1C39400042BCA /* Build configuration list for PBXNativeTarget "Combine-Study" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8DB088B22EF1C39400042BCA /* Debug */, + 8DB088B32EF1C39400042BCA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 8DB089512EF1D06900042BCA /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.7.1; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 8DB089522EF1D06900042BCA /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 8DB089512EF1D06900042BCA /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 8DB088962EF1C39200042BCA /* Project object */; +} diff --git a/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..747f717 --- /dev/null +++ b/Combine-Study/Combine-Study.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "4cdad746817ac9ed37e44dbe90a2ff25fc018954899b7d513e41a4bfc70f065a", + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit", + "state" : { + "revision" : "2842e6e84e82eb9a8dac0100ca90d9444b0307f4", + "version" : "5.7.1" + } + } + ], + "version" : 3 +} diff --git a/Combine-Study/Combine-Study/APIHelper.swift b/Combine-Study/Combine-Study/APIHelper.swift new file mode 100644 index 0000000..c764415 --- /dev/null +++ b/Combine-Study/Combine-Study/APIHelper.swift @@ -0,0 +1,21 @@ +// +// APIHelper.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +enum APIHelper { + + static func fetch(url: URL?) async throws -> T { + guard let url else { + throw URLError(.badURL) + } + let (data, _) = try await URLSession.shared.data(from: url) + let decoded = try JSONDecoder().decode(T.self, from: data) + return decoded + } + +} diff --git a/Combine-Study/Combine-Study/AppDelegate.swift b/Combine-Study/Combine-Study/AppDelegate.swift new file mode 100644 index 0000000..68fc87e --- /dev/null +++ b/Combine-Study/Combine-Study/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Combine-Study/Combine-Study/Assets.xcassets/AccentColor.colorset/Contents.json b/Combine-Study/Combine-Study/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Combine-Study/Combine-Study/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Combine-Study/Combine-Study/Assets.xcassets/AppIcon.appiconset/Contents.json b/Combine-Study/Combine-Study/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2305880 --- /dev/null +++ b/Combine-Study/Combine-Study/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Combine-Study/Combine-Study/Assets.xcassets/Contents.json b/Combine-Study/Combine-Study/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Combine-Study/Combine-Study/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Combine-Study/Combine-Study/Base.lproj/LaunchScreen.storyboard b/Combine-Study/Combine-Study/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Combine-Study/Combine-Study/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Combine-Study/Combine-Study/BoxOfficeResponse.swift b/Combine-Study/Combine-Study/BoxOfficeResponse.swift new file mode 100644 index 0000000..8bd13d0 --- /dev/null +++ b/Combine-Study/Combine-Study/BoxOfficeResponse.swift @@ -0,0 +1,30 @@ +// +// BoxOfficeResponse.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +extension MovieAPI { + + struct BoxOfficeResponse: Decodable { + let boxOfficeResult: BoxOfficeResult + } + + struct BoxOfficeResult: Decodable { + let boxofficeType: String + let showRange: String + let dailyBoxOfficeList: [DailyBoxOffice] + } + + struct DailyBoxOffice: Decodable { + let rank: String + let rankInten: String + let movieNm: String + let openDt: String + let salesAcc: String + let audiCnt: String + let audiAcc: String + } + +} diff --git a/Combine-Study/Combine-Study/Info.plist b/Combine-Study/Combine-Study/Info.plist new file mode 100644 index 0000000..0eb786d --- /dev/null +++ b/Combine-Study/Combine-Study/Info.plist @@ -0,0 +1,23 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + + diff --git a/Combine-Study/Combine-Study/MovieAPI.swift b/Combine-Study/Combine-Study/MovieAPI.swift new file mode 100644 index 0000000..19eb70c --- /dev/null +++ b/Combine-Study/Combine-Study/MovieAPI.swift @@ -0,0 +1,46 @@ +// +// MovieAPI.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +struct MovieAPI { + + static func fetch() async throws -> [DailyBoxOffice] { + let fetched: BoxOfficeResponse = try await APIHelper.fetch(url: url) + return fetched.boxOfficeResult.dailyBoxOfficeList + } + +} + +extension MovieAPI { + + private static var url: URL? { + let param = params + .map { "\($0.key)=\($0.value)" } + .joined(separator: "&") + let url = Constants.baseURL + "?" + param + return URL(string: url) + } + + private static var params: [String: Any] { + [ + "key": Constants.apiKey, + "targetDt": "20251216", + "repNationCd": "K" + ] + } + +} + +extension MovieAPI { + + private enum Constants { + static let apiKey = "1e0e28f5603a7ff6e4038ebd37d0fdd7" + static let baseURL = "https://www.kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json" + } + +} diff --git a/Combine-Study/Combine-Study/MovieCell.swift b/Combine-Study/Combine-Study/MovieCell.swift new file mode 100644 index 0000000..8e67987 --- /dev/null +++ b/Combine-Study/Combine-Study/MovieCell.swift @@ -0,0 +1,98 @@ +// +// MovieCell.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit +import SnapKit + +final class MovieCell: UITableViewCell { + + static let identifier = "MovieCell" + + private let rankLabel = UILabel() + private let rankIntenLabel = UILabel() + private let titleLabel = UILabel() + private let openDateLabel = UILabel() + private let audienceLabel = UILabel() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setUI() + setLayout() + } + + required init?(coder: NSCoder) { + fatalError() + } + + private func setUI() { + selectionStyle = .none + + rankLabel.font = .boldSystemFont(ofSize: 16) + rankLabel.textColor = .systemBlue + + rankIntenLabel.font = .boldSystemFont(ofSize: 15) + + titleLabel.font = .systemFont(ofSize: 15, weight: .semibold) + titleLabel.numberOfLines = 2 + + openDateLabel.font = .systemFont(ofSize: 12) + openDateLabel.textColor = .darkGray + + audienceLabel.font = .systemFont(ofSize: 12) + audienceLabel.textColor = .gray + } + + private func setLayout() { + contentView.addSubviews( + rankLabel, + rankIntenLabel, + titleLabel, + openDateLabel, + audienceLabel + ) + + rankLabel.snp.makeConstraints { + $0.leading.equalToSuperview().offset(16) + $0.top.equalToSuperview().offset(16) + } + + rankIntenLabel.snp.makeConstraints { + $0.trailing.equalToSuperview().inset(16) + $0.top.equalToSuperview().offset(16) + } + + titleLabel.snp.makeConstraints { + $0.leading.equalTo(rankLabel.snp.trailing).offset(12) + $0.trailing.equalToSuperview().inset(16) + $0.top.equalTo(rankLabel) + } + + openDateLabel.snp.makeConstraints { + $0.leading.equalTo(titleLabel) + $0.top.equalTo(titleLabel.snp.bottom).offset(6) + } + + audienceLabel.snp.makeConstraints { + $0.leading.equalTo(titleLabel) + $0.top.equalTo(openDateLabel.snp.bottom).offset(4) + $0.bottom.equalToSuperview().inset(16) + } + } + +} + +extension MovieCell { + + func configure(with movie: MovieAPI.DailyBoxOffice) { + rankLabel.text = movie.rank + rankIntenLabel.text = "\(movie.rankInten)위 변동" + titleLabel.text = movie.movieNm + openDateLabel.text = "개봉일: \(movie.openDt)" + audienceLabel.text = "누적 관객 수: \(movie.audiAcc)" + } + +} diff --git a/Combine-Study/Combine-Study/MovieView.swift b/Combine-Study/Combine-Study/MovieView.swift new file mode 100644 index 0000000..b3b9973 --- /dev/null +++ b/Combine-Study/Combine-Study/MovieView.swift @@ -0,0 +1,55 @@ +// +// MovieView.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit +import SnapKit + +final class MovieView: UIView { + + let tableView = UITableView() + let loadingIndicator = UIActivityIndicatorView(style: .medium) + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + setLayout() + } + + required init?(coder: NSCoder) { + fatalError() + } + + private func setup() { + addSubviews( + tableView, + loadingIndicator + ) + } + + private func setLayout() { + tableView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + + loadingIndicator.snp.makeConstraints { + $0.center.equalToSuperview() + } + } + +} + +extension MovieView { + + func updateLoading(isLoading: Bool) { + if isLoading { + loadingIndicator.startAnimating() + } else { + loadingIndicator.stopAnimating() + } + } + +} diff --git a/Combine-Study/Combine-Study/MovieViewController.swift b/Combine-Study/Combine-Study/MovieViewController.swift new file mode 100644 index 0000000..60956cb --- /dev/null +++ b/Combine-Study/Combine-Study/MovieViewController.swift @@ -0,0 +1,76 @@ +// +// MovieViewController.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit +import Combine + +final class MovieViewController: UIViewController { + + private let movieView = MovieView() + private let viewModel = MovieViewModel() + private var cancellables = Set() + + private var dataSource: [MovieAPI.DailyBoxOffice] = [] + + override func loadView() { + view = movieView + } + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .white + setTableView() + bind() + viewModel.load() + } + + private func setTableView() { + movieView.tableView.dataSource = self + movieView.tableView.register( + MovieCell.self, + forCellReuseIdentifier: MovieCell.identifier + ) + } + + private func bind() { + viewModel.movies + .sink { [weak self] movies in + self?.dataSource = movies + self?.movieView.tableView.reloadData() + } + .store(in: &cancellables) + + viewModel.isLoading + .sink { [weak self] isLoading in + self?.movieView.updateLoading(isLoading: isLoading) + } + .store(in: &cancellables) + } + +} + +extension MovieViewController: UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + dataSource.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + + guard let cell = tableView.dequeueReusableCell( + withIdentifier: MovieCell.identifier, + for: indexPath + ) as? MovieCell else { + return UITableViewCell() + } + + let movie = dataSource[indexPath.row] + cell.configure(with: movie) + return cell + } + +} diff --git a/Combine-Study/Combine-Study/MovieViewModel.swift b/Combine-Study/Combine-Study/MovieViewModel.swift new file mode 100644 index 0000000..436e6b2 --- /dev/null +++ b/Combine-Study/Combine-Study/MovieViewModel.swift @@ -0,0 +1,29 @@ +// +// MovieViewModel.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import Combine + +final class MovieViewModel { + + let movies = PassthroughSubject<[MovieAPI.DailyBoxOffice], Never>() + let isLoading = PassthroughSubject() + + func load() { + isLoading.send(true) + + Task { + do { + let result = try await MovieAPI.fetch() + movies.send(result) + } catch { + print("에러에러에러에러: \(error)") + } + isLoading.send(false) + } + } + +} diff --git a/Combine-Study/Combine-Study/SceneDelegate.swift b/Combine-Study/Combine-Study/SceneDelegate.swift new file mode 100644 index 0000000..b142aec --- /dev/null +++ b/Combine-Study/Combine-Study/SceneDelegate.swift @@ -0,0 +1,56 @@ +// +// SceneDelegate.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + + guard let windowScene = (scene as? UIWindowScene) else { return } + + let window = UIWindow(windowScene: windowScene) + let vc = MovieViewController() + window.rootViewController = vc + self.window = window + window.makeKeyAndVisible() + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/Combine-Study/Combine-Study/UIView+.swift b/Combine-Study/Combine-Study/UIView+.swift new file mode 100644 index 0000000..21ee131 --- /dev/null +++ b/Combine-Study/Combine-Study/UIView+.swift @@ -0,0 +1,14 @@ +// +// UIView+.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +extension UIView { + func addSubviews(_ views: UIView...) { + views.forEach { addSubview($0) } + } +} diff --git a/Combine-Study/Combine-Study/ViewController.swift b/Combine-Study/Combine-Study/ViewController.swift new file mode 100644 index 0000000..7f99446 --- /dev/null +++ b/Combine-Study/Combine-Study/ViewController.swift @@ -0,0 +1,19 @@ +// +// ViewController.swift +// Combine-Study +// +// Created by 이상수 on 12/17/25. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} +