NSUserDefaults — A Swift Introduction


NSUserDefaults 는 안드로이드 Preference와 같은 기능을 수행합니다.

간단한 데이터인 경우 구지 데이터베이스를 생성하지 않고도 NSUserDefaults를 이용하여 자료를 저장 

할 수 있습니다.


[사용방법]

let pref = NSUserDefaults.standardUserDefaults()//NSUserDefaults 클래스 참조

pref.setValue("Hello", forKey: "abcd")//앞에서부터 "저장할 데이터", "키값"

print(pref.stringForKey("abcd"))//키값을 이용하여 저장된 데이터 불러오기


아래 내용은 NSUserDfaults와 관련된 애플 개발자 사이트의 설명글입니다.

영어 실력이 시원치 않아 원문을 보고 싶으신 분은

https://developer.apple.com/reference/foundation/userdefaults

로 접속하여 보시면 되겠습니다.

Class

UserDefaults

The NSUserDefaults class provides a programmatic interface for interacting with the defaults system.

NSUserDefaults 클래스는 기본 시스템과 상호 작용할 수있는 프로그래밍 인터페이스를 제공합니다.

 

The defaults system allows an application to customize its behavior to match a user’s preferences.

디폴트 시스템은 사용자의 선호에 맞게 사용자 정의 프로그램 동작을 지정해 줍니다.

 

For example, you can allow users to determine what units of measurement your application displays or how often documents are automatically saved.

예를 들어 어플에 표시된 어떠한 측정 단위나 얼마나 자주 문서를 자동으로 저장할지를 사용자가 결정할 수 있도록 해줄 수 있습니다.

 

Applications record such preferences by assigning values to a set of parameters in a user’s defaults database.

어플리케이션은 사용자 디폴트 데이터베이스 내에 있는 매개 변수 집합으로 각각 선호하는 값을 기록 합니다.


The parameters are referred to as defaults since they’re commonly used to determine an application’s default state at startup or the way it acts by default.

매개 변수는 시작 시 응용 프로그램의 기본 상태 또는 기본적으로 작동하는 방식을 결정하는 데 일반적으로 사용되므로 기본 값으로 참조된다,


해석한다고 해봤지만 뭔소린지 모르겠네요...

전 이만 도망가보겠습니다!

포스트에 관한 피드백은 언제나 환영입니다.



Posted by MAESTRO.
,