Skip to content

Commit

Permalink
Merge pull request #3523 from vishalduggal/timob-11399
Browse files Browse the repository at this point in the history
[TIMOB-11399] Use NSKeyedArchiver/Unarchiver to set/get Objects
  • Loading branch information
srahim committed Dec 6, 2012
2 parents 1066f7b + cea09c6 commit 8e02c0c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions iphone/Classes/TiAppPropertiesProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ -(id)getList:(id)args

-(id)getObject:(id)args
{
GETPROP
return [defaultsObject dictionaryForKey:key];
GETPROP
id theObject = [defaultsObject objectForKey:key];
if ([theObject isKindOfClass:[NSData class]]) {
return [NSKeyedUnarchiver unarchiveObjectWithData:theObject];
}
else {
return theObject;
}
}

#define SETPROP \
Expand Down Expand Up @@ -147,9 +153,10 @@ -(void)setList:(id)args

-(void)setObject:(id)args
{
SETPROP
[defaultsObject setObject:value forKey:key];
[defaultsObject synchronize];
SETPROP
NSData* encoded = [NSKeyedArchiver archivedDataWithRootObject:value];
[defaultsObject setObject:encoded forKey:key];
[defaultsObject synchronize];
}

-(void)removeProperty:(id)args
Expand Down

0 comments on commit 8e02c0c

Please sign in to comment.