본문 바로가기

IOS50

Swift 주기별로 함수 실행하기( 타이머 ) 클로저를 통한 타이머 실행방법 let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in print("timer") } 타이머를 등록하여 사용 하는 방법 Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerFunc), userInfo: nil, repeats: true) @objc func timerFunc() { print("timer") } timeInterval를 수정하여 시간을 조절합니다. 2021. 12. 16.
Swift AppDelegate에서 ViewController 참조하기 if let vc = window?.rootViewController as? ViewController { //vc.?? 하여 참조 } 루트뷰를 이용하여 가능합니다. as? ViewController에서 ViewController은 해당 루트뷰에 대한 클래스명을 적어주시면 됩니다. 루트뷰를 만드는 방법은 https://onedaycodeing.tistory.com/163 Swift rootView 변경하기. let ad = UIApplication.shared.delegate as! AppDelegate //델리데이트 값 받아오기. ad.window?.rootViewController = self //루트뷰를 현재 메인뷰로 변경 해당 2줄로 간단하게 해결 가능합니다. onedaycodeing.tistor.. 2021. 12. 8.
Swift rootView 변경하기. let ad = UIApplication.shared.delegate as! AppDelegate //델리데이트 값 받아오기. ad.window?.rootViewController = self //루트뷰를 현재 메인뷰로 변경 해당 2줄로 간단하게 해결 가능합니다. 2021. 12. 8.
Swift FCM에서 보낸 데이터를 앱 사용중 실시간 파싱 앱을 사용하는 도중 fcm에서 보낸 KEY VALUE 의 값을 계속해서 받아 볼 수 있는 방법. AppDelegate에서 extension AppDelegate : UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter,willPresent notification: UNNotification,withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions)-> Void) { let userInfo = notification.request.content.userInfo print(userInfo["gcm.. 2021. 12. 8.