Hi there,
an initial commit of a simple property list based store has been merged. It can be used
using the regular store interface just passing a PLIST type during creation.
A simple example storing e.g. an otp secret
// initalize plist store (if the file does not exist it will be created)
AGDataManager* manager = [AGDataManager manager];
id<AGStore> plistStore = [manager store:^(id<AGStoreConfig> config) {
[config setName:@"secrets"]; // will be used as the filename for the
plist
[config setType:@"PLIST"];
}];
// the object to save
NSDictionary *otp = [NSDictionary
dictionaryWithObjectsAndKeys:@"19a01df0281afcdbe", @"otp",
@"1", @"id", nil];
// save it
[plistStore save:otp success:^(id object) {
STAssertNotNil(object, @"object should not be nil");
} failure:^(NSError *error) {
NSLog(@"error: %@", error);
}];
//... at some later time
// initialize store from file
id<AGStore> plistStore = [manager store:^(id<AGStoreConfig> config) {
[config setName:@"secrets"];
[config setType:@"PLIST"];
}];
// read the otp
[plistStore read:@"1" success:^(id object) {
NSLog(@"otp secret is: %@", [object objectForKey:@"otp");
} failure:^(NSError *error) {
NSLog(@"error: %@", error);
}];
Let me know if you have comments/suggestions
Thanks
Christos
On Jan 8, 2013, at 4:38 PM, Christos Vasilakis <cvasilak(a)gmail.com> wrote:
Hi team,
fyi,
in order to have some long-term storage of data (for example storing the OTP secret), I
am writing a simple PropertyList based implementation of AGStore. It will provide the same
interface as the AGStore that is save, read and remove of data and internally will use the
Property List mechanism for iOS. As with all other implementations, a configuration
object will be used to passed in the parameters (e.g. filename of the archive etc.) . A
ticket has been opened to track this [1].
More info as I progress.
Thanks,
Christos
[1]
https://issues.jboss.org/browse/AEROGEAR-783