Skip to content

Latest commit

Β 

History

History
100 lines (75 loc) Β· 2.33 KB

File metadata and controls

100 lines (75 loc) Β· 2.33 KB

μ½”λ“œ λ ˆμ΄μ•„μ›ƒ

λ“€μ—¬μ“°κΈ° 및 띄어쓰기

  • λ“€μ—¬μ“°κΈ°μ—λŠ” νƒ­(tab) λŒ€μ‹  2개의 spaceλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

  • 콜둠(:)을 μ“Έ λ•Œμ—λŠ” 콜둠의 였λ₯Έμͺ½μ—λ§Œ 곡백을 λ‘‘λ‹ˆλ‹€.

    static let identifier: String = "MainVC"

μž„ν¬νŠΈ

λͺ¨λ“ˆ μž„ν¬νŠΈλŠ” μ•ŒνŒŒλ²³ 순으둜 μ •λ ¬ν•©λ‹ˆλ‹€. λ‚΄μž₯ ν”„λ ˆμž„μ›Œν¬λ₯Ό λ¨Όμ € μž„ν¬νŠΈν•˜κ³ , 빈 μ€„λ‘œ κ΅¬λΆ„ν•˜μ—¬ μ„œλ“œνŒŒν‹° ν”„λ ˆμž„μ›Œν¬λ₯Ό μž„ν¬νŠΈν•©λ‹ˆλ‹€.

import UIKit

import SwiftyColor
import SwiftyImage
import Then
import URLNavigator

넀이밍

클래슀

  • 클래슀 μ΄λ¦„μ—λŠ” UpperCamelCaseλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
class MainVC: UIViewController
class PopUpCell: UITableViewCell

ν•¨μˆ˜

  • ν•¨μˆ˜ μ΄λ¦„μ—λŠ” lowerCamelCaseλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
  • ν•¨μˆ˜ 이름 μ•žμ—λŠ” λ˜λ„λ‘μ΄λ©΄ get을 뢙이지 μ•ŠμŠ΅λ‹ˆλ‹€.
 private func setbattleInformation()
 private func authorizeHealthKit()
  • λ²„νŠΌ 클릭 μ‹œ Action ν•¨μˆ˜λŠ” λ²„νŠΌ 이름 + DidTab μ΄λ¦„μœΌλ‘œ μ •μ˜ν•©λ‹ˆλ‹€.
@IBAction func runButtonDidTap(_ sender: Any)
  • 각 뷰의 viewDidLoad() ν•¨μˆ˜ μ•ˆμ—λŠ” μ΅œλŒ€ν•œ ν•¨μˆ˜λ§Œ μ‚¬μš©ν•©λ‹ˆλ‹€.
    override func viewDidLoad() {
        super.viewDidLoad()
        mainBasicLayout()
        setbattleInformation()
    }
  • κΈ°λ³Έ λ ˆμ΄μ•„μ›ƒλ“€μ€ ν•¨μˆ˜λ‘œ λ§Œλ“€μ–΄μ„œ viewDidLoad()에 λ„£μ–΄μ€λ‹ˆλ‹€.
func mainBasicLayout() {
        self.view.backgroundColor = UIColor.salmon
        secondView.backgroundColor = UIColor.white
        secondView.layer.cornerRadius = 20
        runButton.backgroundColor = UIColor.lightishBlue

λ³€μˆ˜,μƒμˆ˜

  • λ³€μˆ˜(var)와 μƒμˆ˜(let) μ΄λ¦„μ—λŠ” lowerCamelCaseλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

μ—΄κ±°ν˜•

  • enum의 각 caseμ—λŠ” lowerCamelCaseλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

    쒋은 예:

    enum Result {
      case .success
      case .failure
    }

    λ‚˜μœ 예:

    enum Result {
      case .Success
      case .Failure
    }

ν΄λž˜μŠ€μ™€ ꡬ쑰체

  • ν΄λž˜μŠ€μ™€ ꡬ쑰체 λ‚΄λΆ€μ—μ„œλŠ” selfλ₯Ό λͺ…μ‹œμ μœΌλ‘œ μ‚¬μš©ν•©λ‹ˆλ‹€.

  • ꡬ쑰체λ₯Ό 생성할 λ•Œμ—λŠ” Swift ꡬ쑰체 μƒμ„±μžλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

    쒋은 예:

    UIColor(red: 253.0 / 255.0, green: 85.0 / 255.0, blue: 85.0 / 255.0, alpha: 1.0)