Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

박스오피스 앱 [Step3] 이지, 희동 #60

Open
wants to merge 18 commits into
base: d_Hidong
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 94 additions & 77 deletions BoxOffice.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions BoxOffice/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
UINavigationBar.appearance().standardAppearance = appearance
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.
Expand Down
37 changes: 14 additions & 23 deletions BoxOffice/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,34 @@
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }

func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
let mainViewController = MovieListViewController()
let navigationController = UINavigationController(rootViewController: mainViewController)
window?.rootViewController = navigationController
navigationController.view.backgroundColor = .white
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.
}


Expand Down
25 changes: 0 additions & 25 deletions BoxOffice/Base.lproj/LaunchScreen.storyboard

This file was deleted.

33 changes: 0 additions & 33 deletions BoxOffice/Base.lproj/Main.storyboard

This file was deleted.

29 changes: 29 additions & 0 deletions BoxOffice/Extension/Date+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Date+.swift
// BoxOffice
//
// Created by dopamint on 3/19/24.
//

import Foundation

extension Date {
static let yyyyMMdd = "yyyyMMdd"
static let yyyyMMddHyphen = "yyyy-MM-dd"

func yesterday(format: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
dateFormatter.timeZone = TimeZone(abbreviation: "UTC")

let today = Date()
let timezone = TimeZone.autoupdatingCurrent
let secondsFromGMT = timezone.secondsFromGMT(for: today)
let localizedDate = today.addingTimeInterval(TimeInterval(secondsFromGMT))
let yesterday = Calendar(identifier: .gregorian).date(byAdding: .day, value: -1, to: localizedDate)
guard let dateString = dateFormatter.string(for: yesterday) else {
return "알 수 없는 날짜"
}
return dateString
}
}
21 changes: 21 additions & 0 deletions BoxOffice/Extension/String+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// String+.swift
// BoxOffice
//
// Created by dopamint on 3/19/24.
//

import Foundation

extension String {
func formatNumberString() -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
guard let number = Double(self),
let result = formatter.string(from: NSNumber(value: number))
else {
return ""
}
return result
}
}
Comment on lines +10 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 메서드의 네이밍만 보고서는 이 메서드의 역할을 추측할 수 없어요. 더 구체적인 네이밍이 필요해요.
  • �self가 숫자형이 될 수 없다면 나머지 로직은 모두 불필요하므로 guard let 바인딩이 앞부분에 나오는 게 좋아보여요.
  • NSNumber 같은 타입을 여기서 쓸 필요는 없어 보여요. NumberFormatter의 string(for:) 메서드를 쓰면 될 것 같아요.
  • 문제가 있을 경우 ""를 반환하기보다는 차라리 원래의 스트링을 반환하는 게 좋아보여요. 또, 그보다는 String?을 반환하도록 해 실패할 수 있는 메서드라는 걸 알 수 있도록 해주는 게 더 좋아보이고요.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음과 같이 수정해 보았습니다!

extension String {
    func formatToDecimal() -> String? {
        let formatter = NumberFormatter()
        guard let number = Double(self),
              let result = formatter.string(for: number)
        else {
            return nil
        }
        formatter.numberStyle = .decimal
        return result
    }
}

2 changes: 0 additions & 2 deletions BoxOffice/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
Expand Down
11 changes: 5 additions & 6 deletions BoxOffice/Model/DTO/DailyBoxOfficeDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@

import Foundation

struct DailyBoxOfficeResultDTO: Decodable {
struct DailyBoxOfficeDTO: Decodable {
let boxOfficeResult: BoxOfficeDTO
}

extension DailyBoxOfficeResultDTO {
extension DailyBoxOfficeDTO {
struct BoxOfficeDTO: Decodable {
let boxOfficeType: String
let dateRange: String
let dailyBoxOfficeList: [MovieInfo]?
}

}

extension DailyBoxOfficeResultDTO.BoxOfficeDTO {
extension DailyBoxOfficeDTO.BoxOfficeDTO {
enum CodingKeys: String, CodingKey {
case dateRange = "showRange"
case boxOfficeType = "boxofficeType"
case dailyBoxOfficeList
}
}

extension DailyBoxOfficeResultDTO.BoxOfficeDTO {
extension DailyBoxOfficeDTO.BoxOfficeDTO {
struct MovieInfo: Decodable {
let rankNumber: String
let rank: String
Expand All @@ -51,7 +50,7 @@ extension DailyBoxOfficeResultDTO.BoxOfficeDTO {
}
}

extension DailyBoxOfficeResultDTO.BoxOfficeDTO.MovieInfo {
extension DailyBoxOfficeDTO.BoxOfficeDTO.MovieInfo {
enum CodingKeys: String, CodingKey {
case rankNumber = "rnum"
case rank
Expand Down
16 changes: 8 additions & 8 deletions BoxOffice/Model/DTO/MovieDetailDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ extension MovieDetailDTO.MovieInfoDTO {
let openDate: String
let productionStatusName: String
let typeName: String
let nations: [Nation]
let genres: [Genre]
let directors: [Director]
let actors: [Actor]
let showTypes: [ShowType]
let companys: [Company]
let audits: [Audit]
let staffs: [Staff]
let nations: [NationDTO]
let genres: [GenreDTO]
let directors: [DirectorDTO]
let actors: [ActorDTO]
let showTypes: [ShowTypeDTO]
let companys: [CompanyDTO]
let audits: [AuditDTO]
let staffs: [StaffDTO]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Actor: Decodable {
struct ActorDTO: Decodable {
let peopleName: String
let peopleNameInEnglish: String
let cast: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Audit: Decodable {
struct AuditDTO: Decodable {
let auditNumber: String
let watchGradeName: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Company: Decodable {
struct CompanyDTO: Decodable {
let companyCode: String
let companyName: String
let companyNameInEnglish: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Director: Decodable {
struct DirectorDTO: Decodable {
let peopleName: String
let peopleNameInEnglish: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Genre: Decodable {
struct GenreDTO: Decodable {
let genreName: String

enum CodingKeys: String, CodingKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Nation: Decodable {
struct NationDTO: Decodable {
let nationName: String

enum CodingKeys: String, CodingKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct ShowType: Decodable {
struct ShowTypeDTO: Decodable {
let showTypeGroupName: String
let showTypeName: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by dopamint on 2/18/24.
//

struct Staff: Decodable {
struct StaffDTO: Decodable {
let peopleName: String
let peopleNameInEnglish: String
let staffRoleName: String
Expand Down
Loading