iOS/iOS SeSAC 2기 TIL

[iOS swift] UserDefaults 앱 최초 사용자/ 기존 사용자 구분하여 화면 전환

Developer-Michelle 2022. 8. 16. 21:17

UserDefaults 앱 최초 사용자/ 기존 사용자 구분하여 화면 전환

 

Framework 에 Storage.swift 파일 저장하여 public 클래스 안에 public 메서드로 선언한 뒤

프로젝트로 해당 파일에 선언한 메서드를 데리고와서 이용함

 

Storage.swift 파일

경험한 오류:

해당 메서드 Storage.isFirstTime()을 프로젝트에서 이용하려고하니 오류가 났었는데

public class안에 public으로 메서드를 선언했어야 했다. public 빼먹으면 안됨!!!

 

그리고 아래처럼 프로젝트에서 위의 메서드를 이용해서 최초 이용자인지 아닌지 판단하여

최초이용자의 경우 해당 뷰 (페이지뷰컨트롤러) 그대로 띄워줌, 기존 이용자의 경우 Netflix뷰 띄워줌.

 

 

참조한 문서들 ->

 

https://jellysong.tistory.com/70

 

[iOS/Swift] UserDefaults 를 이용해 데이터 저장하기, 앱 최초 실행 여부 판단하기

👀 UserDefaults class UserDefaults : NSObject 💡 An interface to the user’s defaults database, where you store key-value pairs persistently across launches of your app. 사용자의 defaults 데이터베이..

jellysong.tistory.com

https://jellysong.tistory.com/71

 

[iOS/Swift] 온보딩(Onboarding) 페이지 만들기 - Storyboard, UserDefaults, SceneDelegate

💡 온보딩, Onboarding 온보딩 페이지는 새로운 유저나 다시 돌아온 유저를 환영해주는 역할을 한다. 유저에게 어플의 사용법을 알려주거나 기능에 대한 팁, 콘텐츠 샘플 등을 보여주기 위해 사용

jellysong.tistory.com

https://mini-min-dev.tistory.com/104

 

[iOS] 온보딩(Onboarding) 화면을 만들어보자

오늘은 온보딩(Onboarding) 화면을 구현하고 연결하는 방법에 대해 글을 써보려고 한다. 온보딩(Onboarding)이란 사용자가 앱을 처음 들어왔을 때, 기본적인 앱에 대한 소개와 새로운 사용자에 대한 환

mini-min-dev.tistory.com

 

 

위 과정 중 경험한 오류 => modal Present로 화면 띄우는 경우, viewDidLoad 에서 하면 아래의 오류가 남

"whose view is not in the window hierarchy."

해결책 => viewDidAppear에서 modal present로 화면 띄워줘야함

 

https://velog.io/@ellyheetov/errorhandling01

 

[iOS] whose view is not in the window hierarchy 오류 해결

컴파일 에러는 없지만, 앱을 실행한 뒤 console에 "whose view is not in the window hierarchy" 로그가 있다. 해당 오류는 UIViewController의 override 함수인 viewDidLoad()에서 모달 뷰를 띄울 때 발생

velog.io