The missing implementation of NSUserDefaultsController for iOS.
Objective-C Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


PNDUserDefaultsController is a KVO-compatible controller class. Properties of the shared instance of this class can be bound to user interface elements to access and modify values stored in NSUserDefaults.

PNDUserDefaultsController is a class for iOS 4.3 and newer.


PNDUserDefaultsController can be added to a project using CocoaPods.


  1. Subclass PNDUserDefaultsController.m
  2. Add properties for each user default you want to model.
  3. Bind properties to user defaults by overriding +propertiesForUserDefaultsKeys.


In XYUserDefaultsController.h:

//  XYUserDefaultsController.h
//  Created by Pandamonia LLC on 2/15/13.
//  Copyright (c) 2013 Pandamonia LLC. All rights reserved.

#import "PNDUserDefaultsController.h"

extern NSString *const XYUserAcceptedTermsOfServiceKey;
extern NSString *const XYUsernameKey;

@interface XYUserDefaultsController : PNDUserDefaultsController

@property (nonatomic) BOOL acceptedTermsOfService;
@property (nonatomic) NSString *username;


In XYUserDefaultsController.m:

//  XYUserDefaultsController.m
//  Created by Pandamonia LLC on 2/15/13.
//  Copyright (c) 2013 Pandamonia LLC. All rights reserved.

#import "XYUserDefaultsController.h"

NSString *const XYUserAcceptedTermsOfServiceKey = @"XYAcceptedTermsOfService";
NSString *const XYUsernameKey = @"XYUsername";

@implementation XYUserDefaultsController


Depending on your version of Xcode, you may need to  include the following variable synthesis:

@synthesize acceptedTermsOfService = _acceptedTermsOfService;
@synthesize username = _username


+ (NSDictionary *)propertiesForUserDefaultsKeys
	static NSDictionary *propertiesForUserDefaultsKeys;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		propertiesForUserDefaultsKeys = @{
			@"acceptedTermsOfService": XYUserAcceptedTermsOfServiceKey,
			@"username": XYUsernameKey
	return propertiesForUserDefaultsKeys;



PNDUserDefaultsController is created and maintained by Pandamonia LLC under the MIT license. The project itself is free for use in any and all projects. You can use PNDUserDefaultsController in any project, public or private, with or without attribution - though we prefer attribution! It helps us.

Unsure about your rights? Read more.