일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- basic
- SwiftGen
- reetcode
- GIT
- xcode
- github
- Extentsion
- pubspec
- ToDoRim
- enumerations
- Leetcode
- Widget
- Swift
- algorithm
- UIAccessibility
- IOS
- Equatable
- pubspec.yaml
- designPattern
- dart
- toyproject
- keyWindow
- it
- flutter
- OSLog
- tip
- swiftlint
- protocol
- listview
- COMMIT
- Today
- Total
목록iOS - Swift (47)
수니의 개발새발
📌 이번 글은 두 날짜를 비교해서 과거/현재/미래를 구하는 방법입니다. DateFormatter() extension Date { /** # dateCompare - Parameters: - fromDate: 비교 대상 Date - Note: 두 날짜간 비교해서 과거(Future)/현재(Same)/미래(Past) 반환 */ public func dateCompare(fromDate: Date) -> String { var strDateMessage:String = "" let result:ComparisonResult = self.compare(fromDate) switch result { case .orderedAscending: strDateMessage = "Future" break case .or..
📌 이번 글은 시간을 다른 형태로 변형하는 방법입니다. DateFormatter() extension Date { /** # formatted - Parameters: - format: 변형할 DateFormat - Note: DateFormat으로 변형한 String 반환 */ public func formatted(_ format: String) -> String { let formatter = DateFormatter() formatter.dateFormat = format formatter.timeZone = TimeZone(identifier: TimeZone.current.identifier)! return formatter.string(from: self) } } Date extension에..
📌 이번 글은 현재 시간의 밀리초를 구하는 방법입니다. timeIntervalSince1970 Int(Date().timeIntervalSince1970 / 1000.0) 현재 시간의 밀리초를 구하는 코드입니다. 👩🏻💻 사용 예제 import Foundation extension Date { /** # currentTimeInMilli - Note: 현재 시간의 밀리초 반환 */ public static func currentTimeInMilli() -> Int { return Date().timeInMilli() } /** # timeInMilli - Note: timeIntervalSince1970의 밀리초 반환 */ public func timeInMilli() -> Int { return Int..
📌 이번 글은 외부 브라우저(사파리)로 링크를 여는 방법입니다. UIApplication.shared.open() func openExternalLink(urlStr: String, _ handler:(() -> Void)? = nil) { guard let url = URL(string: urlStr) else { return } if #available(iOS 10.0, *) { UIApplication.shared.open(url, options: [:]) { (result) in handler?() } } else { UIApplication.shared.openURL(url) handler?() } } 사파리로 링크를 여는 함수입니다. 👩🏻💻 사용 예제 import UIKit class Uti..
📌 이번 글은 현재 시뮬레이터 구동 여부를 확인하는 방법입니다. SIMULATOR_DEVICE_NAME func isSimulator() -> Bool { return ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] != nil } 시뮬레이터가 구동 중이면 true를 반환하는 함수입니다. 👩🏻💻 사용 예제 import UIKit class Utils { /** # isSimulator - Returns: Bool - Note: 시뮬레이터 구동 여부 반환 */ static func isSimulator() -> Bool { return ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] ..
iOS4까지는 iOS 기기의 고유 넘버로 udid를 사용하였으나, 개인정보 문제로 iOS5부터는 udid가 사라지고 uudi(임의로 생성한 고유값)를 사용합니다. 📌 이번 글은 디바이스 고유넘버(device uuid)를 구하는 방법입니다. uuidString func getDeviceUUID() -> String { return UIDevice.current.identifierForVendor!.uuidString } 디바이스의 고유 넘버를 구하는 함수입니다. 👩🏻💻 사용 예제 import UIKit class Utils { /** # getDeviceUUID - Note: 디바이스 고유 넘버 반환 */ static func getDeviceUUID() -> String { return UIDevice..
📌 이번 글은 현재 APP의 번들 버전(Bundle Version)을 구하는 방법입니다. CFBundleShortVersionString Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String 현재 APP의 번들 버전을 구하는 코드입니다. 👩🏻💻 사용 예제 import UIKit class Utils { /** # version - Note: 현재 번들 버전 반환 */ static func version() -> String { return Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String } } 공통적으로 사용하는 변수 및 함수들을 Utils 라는 공통 클래스를..
화면을 그리다 보면 노치 영역으로 인해 레이아웃이 깨져 골치 아플 때가 많죠. 그래서 SafeArea Inset값이 디바이스마다 변동되어 자주 필요로 합니다. 📌 이번 글은 현재 디바이스의 SafeArea의 top.bottom 영역 값을 구하는 방법입니다. SafeArea Top Inset func safeAreaTopInset() -> CGFloat { let statusHeight = UIApplication.shared.statusBarFrame.size.height // 상태바 높이 if #available(iOS 11.0, *) { let window = UIApplication.shared.keyWindow let topPadding = window?.safeAreaInsets.top retu..