본문 바로가기

Develop/Swift

(61)
[iOS] XCTest XCTest Xcode Project의 unit test, 성능 test, UI test 케이스를 만들어 실행하는 Framework XCTest | Apple Developer Documentation Create and run unit tests, performance tests, and UI tests for your Xcode project. developer.apple.com ViewController.swift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } } XCTestCase fina..
[iOS] 아이폰에서 Dump뜨기 1. 가상 인터페이스 생성 sudo rvictl -s [UUID] 2. 패킷 캡처 파일 생성 tcpdump -i rvi0 -w [file name].pcapng 3. WireShark로 확인 출처 [iOS_Packet Capture] iOS Network traffic capture without Jailbreak iOS 관련 분석을 진행하다보면 네트워크 트래픽을 관찰해야 할 일이 생기곤 하는데, 모니터 모드 본인 컴퓨터에서 캡쳐하면 무선랜 패킷은 잡을 수 있지만 패킷 손실 우려도 있고... 아무튼 좀 귀 biji-jjigae.tistory.com [번역/의역] 아이폰 패킷 덤프 (tcpdump) # 원문 How to capture network traffic from iPhone with tcpdump..
[iOS] QR코드 리더기 AVCaptureVideoPreviewLayer와 AVCaptureSession 선언 private var videoLayer = AVCaptureVideoPreviewLayer() private var captureSession = AVCaptureSession() 기기가 회전될 때 View도 인식, 그리고 QR코드를 인식하기 위해 함수 선언 override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Camera View rotate Notification NotificationCenter.default.addObserver(self, selector: #selector(orientationChanged(_:)),..
[iOS] LocalAuthentication LocalAuthentication 생체인식이나 이미 알고 있는 암호를 사용하여 사용자 인증 LocalAuthentication을 import 하고, LAcontext를 선언 import LocalAuthentication private var context = LAContext() 인증 시도 함수 var error: NSError? if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) { let reason = "Log in to your account" context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { [weak self] isSucces..
[Swift] URL, URLComponents URL let urlString = "https://ios-development.tistory.com/search/users?id=123&age=20" let url = URL(string: urlString) /// 주소 전체 "https://ios-development.tistory.com/search/users?id=123&age=20" print(url?.absoluteURL) /// 어떤식으로 네트워킹 하는지 "https" print(url?.scheme) /// baseURL과 같이 메인 주소 "ios-development.tistory.com" print(url?.host) /// host뒤에 query parameter를 제외한 주소 "/search/users" print(url?.path..
[Swift] RelativeDateTimeFormatter(상대시간) RelativeDateTimeFormatter RelativeDateTimeFormatter | Apple Developer Documentation A formatter that creates locale-aware string representations of a relative date or time. developer.apple.com extension Date{ var relativeTime_abberiavted: String{ let formatter = RelativeDateTimeFormatter() formatter.unitsStyle = .full // 지역 설정하면 그 나라 언어로 상대시간을 표시 formatter.locale = Locale(identifier: "ko_KR") re..
[Swift] 공식문서 파헤치기 (Array, Set, Dictionary) Array (Struct) 순서가 지정된 무작위 액세스 collection Array | Apple Developer Documentation An ordered, random-access collection. developer.apple.com 배열은 앱에서 가장 많이 사용되는 데이터 타입 중 하나 앱의 데이터를 구성할 때 배열을 사용 특히 배열을 사용하여 단일 유형의 element, 즉 배열의 element 유형을 보유 배열은 Int형부터 String, Class까지 모든 종류의 element를 저장 가능 예전 포스팅 [Swift] 배열 참조 : Swift 스위프트 프로그래밍 3판 Swift 5, 저자 야곰 (한빛미디어) , The Swift Programming Language Swift 5.6 E..
[Swift] UISceneDelegate UISceneDelegate Scene 내에서 발생하는 수명 주기(Life Cycle) 이벤트에 응답하는 데 사용하는 핵심 방법 UISceneDelegate | Apple Developer Documentation The core methods you use to respond to life-cycle events occurring within a scene. developer.apple.com Connecting and disconnecting the scene scene(_:willConnectTo:options:) : Delegate에 앱의 Scene을 추가하는 것을 알림 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, opt..