-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaculatorResult.m
80 lines (68 loc) · 2.14 KB
/
CaculatorResult.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// CaculatorResult.m
// dbm-watt
//
// Created by Patrick Deng on 13-2-23.
// Copyright (c) 2013年 Code Animal. All rights reserved.
//
#import "CaculatorResult.h"
@implementation CaculatorResult
@synthesize dbmValue;
@synthesize wattValue;
@synthesize wattUnit;
@synthesize isDbm2Watt;
@synthesize savedTime;
-(void) encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.dbmValue forKey:CODING_KEY_DBM];
[aCoder encodeObject:self.wattValue forKey:CODING_KEY_WATT];
[aCoder encodeInt:self.wattUnit forKey:CODING_KEY_WATTUNIT];
[aCoder encodeBool:self.isDbm2Watt forKey:CODING_KEY_ISDBM2WATT];
[aCoder encodeObject:self.savedTime forKey:CODING_KEY_SAVEDTIME];
}
-(id) initWithCoder:(NSCoder *)aDecoder
{
if (self=[super init])
{
self.dbmValue = [aDecoder decodeObjectForKey:CODING_KEY_DBM];
self.wattValue = [aDecoder decodeObjectForKey:CODING_KEY_WATT];
self.wattUnit = [aDecoder decodeIntForKey:CODING_KEY_WATTUNIT];
self.isDbm2Watt = [aDecoder decodeBoolForKey:CODING_KEY_ISDBM2WATT];
self.savedTime = [aDecoder decodeObjectForKey:CODING_KEY_SAVEDTIME];
}
return self;
}
-(id) initWithDbmValue:(NSString*) dbm wattValue:(NSString*)watt wattUnit:(WattUnit) unit isDbm2Watt:(BOOL) dbm2watt
{
self = [super init];
if (self)
{
[self setDbmValue:dbm];
[self setWattValue:watt];
[self setWattUnit:unit];
[self setIsDbm2Watt:dbm2watt];
}
return self;
}
-(NSString*) description
{
NSMutableString* string = [NSMutableString stringWithCapacity:0];
if (self.isDbm2Watt)
{
[string appendString:self.dbmValue];
[string appendString:DBM];
[string appendString:EQUAL_CHAR];
[string appendString:self.wattValue];
[string appendString:[CaculatorUIStyle wattUnitString:self.wattUnit]];
}
else
{
[string appendString:self.wattValue];
[string appendString:[CaculatorUIStyle wattUnitString:self.wattUnit]];
[string appendString:EQUAL_CHAR];
[string appendString:self.dbmValue];
[string appendString:DBM];
}
return string;
}
@end