-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSCoderGSA.m
44 lines (35 loc) · 1.09 KB
/
NSCoderGSA.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// NSCoderGSA.m
// AdditionsLib
//
// Created by Guy Shaviv on 1/2/11.
// Copyright 2011 LitePoint Corp. All rights reserved.
//
#import "NSCoderGSA.h"
@implementation NSCoder (GSA)
- (void) encodeIntNumber:(NSInteger)i forKey:(NSString*)key {
[self encodeObject:@(i) forKey:key];
}
- (void) encodeFloatNumber:(float)n forKey:(NSString*)key {
[self encodeObject:@(n) forKey:key];
}
- (void) encodeBoolNumber:(BOOL)n forKey:(NSString*)key {
[self encodeObject:@(n) forKey:key];
}
- (NSUInteger) decodeUnsignedIntNumberForKey:(NSString*)key default:(NSUInteger)d {
NSNumber *n = [self decodeObjectForKey:key];
return n ? [n unsignedIntValue] : d;
}
- (NSInteger) decodeIntNumberForKey:(NSString*)key default:(NSInteger)d {
NSNumber *n = [self decodeObjectForKey:key];
return n ? [n intValue] : d;
}
- (float) decodeFloatNumberForKey:(NSString*)key default:(float)d {
NSNumber *n = [self decodeObjectForKey:key];
return n ? [n floatValue] : d;
}
- (BOOL) decodeBoolNumberForKey:(NSString*)key default:(BOOL)d {
NSNumber *n = [self decodeObjectForKey:key];
return n ? [n boolValue] : d;
}
@end