-
Notifications
You must be signed in to change notification settings - Fork 24
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
박스오피스 앱 [STEP 3] Jin #61
base: d_Sam
Are you sure you want to change the base?
Changes from 13 commits
6dd7f22
fe7cdf2
67147c9
6e8d689
19f2139
9cda8d9
26a0a51
a622e0e
15e82f1
5709ee7
ec8f920
8429e7d
d405c19
37db680
9d3620f
827fe1a
9d9af8a
be26a51
6b4e3bc
0c52589
c57f80e
d9e129d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="g4C-0s-Sww"> | ||
<device id="retina6_12" orientation="portrait" appearance="light"/> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<!--Box Office View Controller--> | ||
<scene sceneID="tne-QT-ifu"> | ||
<objects> | ||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController"> | ||
<viewController id="BYZ-38-t0r" customClass="BoxOfficeViewController" customModule="BoxOffice" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
</view> | ||
<navigationItem key="navigationItem" id="hpq-z3-vqG"/> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="942.74809160305335" y="-34.507042253521128"/> | ||
</scene> | ||
<!--Navigation Controller--> | ||
<scene sceneID="SIH-9C-ylN"> | ||
<objects> | ||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="g4C-0s-Sww" sceneMemberID="viewController"> | ||
<toolbarItems/> | ||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="4ZQ-WP-c2h"> | ||
<rect key="frame" x="0.0" y="59" width="393" height="44"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
</navigationBar> | ||
<nil name="viewControllers"/> | ||
<connections> | ||
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="Qgx-b8-odc"/> | ||
</connections> | ||
</navigationController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="zEL-Of-r7N" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="16.030534351145036" y="-34.507042253521128"/> | ||
</scene> | ||
</scenes> | ||
<resources> | ||
<systemColor name="systemBackgroundColor"> | ||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
</systemColor> | ||
</resources> | ||
</document> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// String+.swift | ||
// BoxOffice | ||
// | ||
// Created by Jin-Mac on 3/20/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension String { | ||
|
||
/// 숫자가 세 자리 이상 넘어가면 ,를 활용하는 메서드 | ||
func formatNumberString() -> String { | ||
let formatter = NumberFormatter() | ||
formatter.numberStyle = .decimal | ||
formatter.locale = Locale.current | ||
if let number = Double(self) { | ||
return formatter.string(from: NSNumber(value: number)) ?? self | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 옵셔널 처리를 하고있네요?? 17째줄에서 함께 언래핑 하는건 어떨까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 같이 수정 했습니다. |
||
} | ||
return self | ||
junbangg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// UILabel+.swift | ||
// BoxOffice | ||
// | ||
// Created by Jin-Mac on 3/20/24. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UILabel { | ||
|
||
/* 텍스트 구간 색상 변경 */ | ||
func setTextColor(_ color: UIColor, range: NSRange) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
guard let attributedString = self.mutableAttributedString() else { return } | ||
|
||
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: range) | ||
self.attributedText = attributedString | ||
} | ||
|
||
/* AttributedString이 설정되어있지 않으면 생성하여 반환한다. */ | ||
private func mutableAttributedString() -> NSMutableAttributedString? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요 주석 또한 최대한 코드로 읽히게 하면 좋을것 같습니다~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석은 제가 했지만, 메서드명을 어떤 식으로 바꿔야 적절한지 찾지 못했습니다. |
||
guard let labelText = self.text, let labelFont = self.font else { return nil } | ||
|
||
var attributedString: NSMutableAttributedString? | ||
if let attributedText = self.attributedText { | ||
attributedString = attributedText.mutableCopy() as? NSMutableAttributedString | ||
} else { | ||
attributedString = NSMutableAttributedString(string: labelText, | ||
attributes: [NSAttributedString.Key.font :labelFont]) | ||
} | ||
|
||
return attributedString | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// UIViewController+.swift | ||
// BoxOffice | ||
// | ||
// Created by Jin-Mac on 3/20/24. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIViewController { | ||
|
||
func presentAlert(title: String, | ||
message: String? = nil, | ||
junbangg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
confirmTitle: String = "확인", | ||
confirmAction: ((UIAlertAction) -> Void)? = nil, | ||
completion: (() -> Void)? = nil) { | ||
let alertViewController = UIAlertController(title: title, message: message, preferredStyle: .alert) | ||
|
||
let confirmAction = UIAlertAction(title: confirmTitle, style: .default) | ||
alertViewController.addAction(confirmAction) | ||
|
||
self.present(alertViewController, animated: true, completion: completion) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
물론 주석이 필요한 경우도 있지만, 메서드명을 통해서 표현을 해보는건 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
메서드 명을 변경해 수정했습니다.
아직은 익숙하지 않아서 그런지 모르겠지만 주석을 추가하는 것이 메서드의 기능을 이해하는데 더 명확하다고 생각하는데
알라딘 의견은 어떤지 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석 없이 자체로 충분히 설명이 될만큼 읽기 좋은 코드를 추구하긴 합니다 개인적으로는!
하지만 필요에 따라서 충분히 주석이 필요한 경우도 있더라고요~
이정도일것 같아요~ 근데 충분히 메서드나 변수명으로 목적이 표현 가능한 코드에 대해서는 네이밍과 단일책임원칙으로 충분히 가독성을 높일 수 있다고 생각합니다!