0Pricing
Objective-C iOS Development for Legacy & Enterprise Apps · 강의

NSUserDefaults로 환경 설정 저장하기

iOS에서 가장 간단한 키-값 저장소인 NSUserDefaults를 사용해 Objective-C 앱에 가벼운 설정과 사용자 환경 설정을 영구 저장하는 방법을 배웁니다.

NSUserDefaults로 환경 설정 저장하기은(는) CoddyKit의 무료 Objective-C iOS Development for Legacy & Enterprise Apps 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Objective-C iOS Development for Legacy & Enterprise Apps 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What is NSUserDefaults?

NSUserDefaults is a built-in key-value store for small pieces of data — settings, flags, and preferences. It persists automatically across app launches.

When to Use It

Use it for small, simple values:

  • User toggles (dark mode on/off)
  • Last selected tab
  • Onboarding-completed flag

Do NOT use it for large data or sensitive secrets.

The Standard Instance

Access the shared store through standardUserDefaults.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

Writing Values

Set values by key with typed setters.

[defaults setBool:YES forKey:@"darkMode"];
[defaults setInteger:5 forKey:@"launchCount"];
[defaults setObject:@"Ada" forKey:@"username"];

Reading Values

Read with matching getters. Missing keys return sensible defaults (NO, 0, nil).

BOOL dark = [defaults boolForKey:@"darkMode"];
NSInteger count = [defaults integerForKey:@"launchCount"];
NSString *name = [defaults stringForKey:@"username"];

Supported Types

NSUserDefaults stores property-list types only:

  • NSString, NSNumber, BOOL, integers, doubles
  • NSArray, NSDictionary (of plist types)
  • NSData, NSDate

Persistence is Automatic

Modern iOS writes changes to disk automatically. The old synchronize call is no longer needed and is deprecated.

// [defaults synchronize]; // no longer required

Registering Default Values

Provide fallback values for first launch with registerDefaults:. These apply only until the user changes them.

[defaults registerDefaults:@{@"darkMode": @NO, @"fontSize": @14}];

Removing a Value

Delete a stored key when it is no longer needed.

[defaults removeObjectForKey:@"username"];

Storing Custom Objects

To store a custom object, archive it to NSData first (it must conform to NSCoding), then save that data. NSUserDefaults cannot hold arbitrary objects directly.

Security Caveat

NSUserDefaults is not encrypted. Never store passwords, tokens, or other secrets there — use the Keychain for sensitive data.

Quick Check

Test your NSUserDefaults knowledge.

Recap

You learned NSUserDefaults persistence:

  • A simple key-value store for small preferences
  • Write with setBool:/setObject:, read with matching getters
  • Stores only property-list types
  • Persistence is automatic; synchronize is deprecated
  • Not encrypted — keep secrets in the Keychain

It is the go-to for lightweight settings.

자주 묻는 질문

“NSUserDefaults로 환경 설정 저장하기” 강의는 무료인가요?

네 — “NSUserDefaults로 환경 설정 저장하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Objective-C iOS Development for Legacy & Enterprise Apps 강의 전체를 잠금 해제할 수 있습니다. Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

“NSUserDefaults로 환경 설정 저장하기”에서 뭘 배우나요?

iOS에서 가장 간단한 키-값 저장소인 NSUserDefaults를 사용해 Objective-C 앱에 가벼운 설정과 사용자 환경 설정을 영구 저장하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Objective-C iOS Development for Legacy & Enterprise Apps을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Objective-C iOS Development for Legacy & Enterprise Apps을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Objective-C iOS Development for Legacy & Enterprise Apps은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“NSUserDefaults로 환경 설정 저장하기” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Objective-C iOS Development for Legacy & Enterprise Apps 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 속성 목록과 보관
  2. Core Data 기초
  3. FMDB를 활용한 SQLite 통합
  4. NSUserDefaults로 환경 설정 저장하기
← Objective-C iOS Development for Legacy & Enterprise Apps(으)로 돌아가기