Skip to main content
Version: Next

설정

Settings는 iOS에서만 사용 가능한 지속적인 키-값 저장소인 NSUserDefaults를 감싸는 래퍼 역할을 한다.

예제


참조

메서드

clearWatch()

tsx
static clearWatch(watchId: number);

watchIdwatchKeys()를 통해 구독을 설정했을 때 반환된 번호이다.

get()

tsx
static get(key: string): any;

NSUserDefaults에서 주어진 key에 해당하는 현재 값을 가져온다.

set()

tsx
static set(settings: Record<string, any>);

NSUserDefaults에 하나 이상의 값을 설정한다.

watchKeys()

tsx
static watchKeys(keys: string | array<string>, callback: () => void): number;

keys 매개변수로 지정된 키 중 하나라도 NSUserDefaults에서 변경되었을 때 알림을 받기 위해 구독한다. clearWatch()와 함께 사용해 구독을 해제할 수 있는 watchId 숫자를 반환한다.

참고: watchKeys()는 설계상 내부 set() 호출을 무시하며, React Native 코드 외부에서 수행된 변경에 대해서만 콜백을 실행한다.