Skip to content

Latest commit

Β 

History

89 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SwiftHelper

iOSμ—μ„œ 자주 μ“°λŠ” Extension / Helper λͺ¨μŒμž…λ‹ˆλ‹€.

SwiftPM compatible Platform License: MIT

Requirements

  • iOS 15.0+
  • Swift 5.9+
  • Xcode 15+

Installation

Swift Package Manager

Xcode β†’ File β†’ Add Package Dependencies… μ—μ„œ μ•„λž˜ URL을 μΆ”κ°€ν•©λ‹ˆλ‹€.

https://github.com/pkh0225/SwiftHelper.git

λ˜λŠ” Package.swift:

dependencies: [
    .package(url: "https://github.com/pkh0225/SwiftHelper.git", from: "1.0.0")
]

μ£Όμš” κΈ°λŠ₯

ToastView

ToastView("ν…ŒμŠ€νŠΈ").show()
ToastView("상단 ν† μŠ€νŠΈ", duration: 2, position: .top).show()
ToastView("ꡐ체", replaceExisting: true).show()

ActionQueue

순차 싀행이 ν•„μš”ν•œ ν΄λ‘œμ € νμž…λ‹ˆλ‹€.

ActionQueue.shared.addAction { _ in
    // work
}
ActionQueue.shared.nextRun()

Scope Functions

let person = Person().apply {
    $0.name = "park"
    $0.age = 10
}

person.run {
    print($0.name)
}

UIAlertController

UIAlertController.alert(title: "μ•Œλ¦Ό", message: "μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.")

let index = await UIAlertController.alert(
    title: "확인",
    message: nil,
    cancelButtonTitle: "μ·¨μ†Œ",
    otherButtonTitles: "확인"
)

RouterProtocol

μŠ€ν† λ¦¬λ³΄λ“œ/μ½”λ“œ 기반 ViewController push helperμž…λ‹ˆλ‹€.

MyViewController.pushViewController()

기타

  • UIScrollView header / footer / sticky header
  • UIView frame helpers, corner radius, debug mask
  • String / Array / Date λ“± FoundationΒ·UIKit Extension
  • @Atomic, @UserDefaultWrapper Property Wrapper
  • os.Logger 기반 μΉ΄ν…Œκ³ λ¦¬ 둜거

Example

Example-iOS/TestSwiftHelper μƒ˜ν”Œ μ•±μ—μ„œ κΈ°λŠ₯을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

ν™”λ©΄ λ‚΄μš©
Closure Queue ActionQueue ν…ŒμŠ€νŠΈ
Scope Scope function ν…ŒμŠ€νŠΈ
ToastView Toast μœ„μΉ˜/duration/νμž‰ λ“±

Structure

Sources/SwiftHelper/
β”œβ”€β”€ Data+Extention/   # String, Array, Date …
β”œβ”€β”€ UI+Extention/     # UIView, UIScrollView, UIAlert …
β”œβ”€β”€ View/             # ToastView, DebugMaskView
β”œβ”€β”€ Scope/            # apply / run / takeIf
β”œβ”€β”€ Wrapper/          # Atomic, UserDefaultWrapper
β”œβ”€β”€ Dispatc/          # gcd helpers, ActionQueue
β”œβ”€β”€ Define/           # Closure typealias
β”œβ”€β”€ Json/             # JSONSerializable
└── ETC/              # Logger, RouterProtocol, Queue

License

MIT