Summary: I have a few details left, but its almost done. This PR addresses #145 - The NSUserDefaults plugin uses the SharedPreferences Desktop Part since we can reuse all of it. - The NSUserDefaults plugin uses swizzling in order to be notified of what specific event changed at runtime. - Added Test harness in both Sample Swift and Sample apps for iOS in order to test the plugin. - Updated the documentation in `docs/shared-preferences-plugin.md` and` README.md` I am open to suggestions since the desktop sharedPreferences version doesn't support deletion of preferences. Most likely I would have to modify the UI, and for that matter, I might as well build a user defaults desktop version I wanted to add xiphirx in this MR since he developed the shared preferences plugin for Android and Desktop. I don't see a way to remove preferences from the flipper desktop app so I was wondering if you would be OK with me adding that. Pull Request resolved: https://github.com/facebook/flipper/pull/291 Reviewed By: passy Differential Revision: D10334685 Pulled By: priteshrnandgaonkar fbshipit-source-id: d798c01a46df7ddecf713924799f046b560ea922
31 lines
799 B
Objective-C
31 lines
799 B
Objective-C
//
|
|
// UserDefaultsViewController.m
|
|
// Sample
|
|
//
|
|
// Created by Marc Terns on 10/7/18.
|
|
// Copyright © 2018 Facebook. All rights reserved.
|
|
//
|
|
|
|
#import "UserDefaultsViewController.h"
|
|
|
|
@interface UserDefaultsViewController ()
|
|
@property (weak, nonatomic) IBOutlet UITextField *valueTextField;
|
|
@property (weak, nonatomic) IBOutlet UITextField *keyTextField;
|
|
@property (nonatomic, strong) NSUserDefaults *userDefaults;
|
|
@end
|
|
|
|
@implementation UserDefaultsViewController
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
|
if (self = [super initWithCoder:aDecoder]) {
|
|
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:nil];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (IBAction)tappedSave:(id)sender {
|
|
[self.userDefaults setObject:self.valueTextField.text forKey:self.keyTextField.text];
|
|
}
|
|
|
|
@end
|