react-native-userdefaults-ios 
React Native Module for NSUserDefaults
This library is especially helpful for hybrid apps that already make use of [NSUserDefaults standardUserDefaults] and would like to read or write to it from within their React components.
Add it to your project
- Run
npm install react-native-userdefaults-ios --save - Open your project in XCode, right click on
Librariesand clickAdd Files to "Your Project Name". - Select the
RNUserDefaults.xcodeprojfile in thenode_modules/react-native-userdefaults-iosfolder and clickAdd - In the Xcode Project Navigator find the
RNUserDefaults.xcodprojand add theProducts/libRNUserDefaultsIOS.atoBuild Phases -> Link Binary With Libraries. - Follow the implementation example below...
Example
// Require the library...var UserDefaults = ;Writing to standardUserDefaults
//Set an Array...var arr = '1' '2' '3';UserDefaults ; // Set a String...UserDefaults ; //Set an Object...var obj = name: 'Dave';UserDefaults ; //Set a boolean value...UserDefaults ; //Remove an item (works for any type)...UserDefaults ;Reading from standardUserDefaults
// Get an array for a given key...UserDefaults ; // Get a string for a given key...UserDefaults ; // Get an object for a given key...UserDefaults ; // Get a boolean value for a given key...UserDefaults ;Todos for 1.0 release
- Implement
dataForKey: - Implement
stringArrayForKey: - Implement
setFloat:forKey: - Implement
floatForKey: - Implement
setInteger:forKey: - Implement
integerForKey: - Implement
setDouble:forKey: - Implement
doubleForKey: - Implement
setURL:forKey: - Implement
URLForKey: - Implement
NSUserDefaultsDidChangeNotification
Todos for 0.1.0 release - DONE!
- Implement
arrayForKey: - Implement
stringForKey: - Implement
setObject:forKey: - Implement
objectForKey: - Implement
removeObjectForKey: - Implement
dictionaryForKey:Note: This was taken care of withobjectForKeysince in JS an Object is a Dictionary in Obj-C - Implement
setBool:forKey: - Implement
boolForKey:
