-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathProvince.m
More file actions
executable file
·67 lines (58 loc) · 1.72 KB
/
Copy pathProvince.m
File metadata and controls
executable file
·67 lines (58 loc) · 1.72 KB
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
//
// Province.m
// ZhiWeiboPhone
//
// Created by junmin liu on 12-8-31.
// Copyright (c) 2012年 idfsoft. All rights reserved.
//
#import "Province.h"
@implementation Province
@synthesize provinceId = _provinceId;
@synthesize name = _name;
@synthesize cities = _cities;
- (id)initWithDictionary:(NSDictionary *)dict {
self = [super init];
if (self) {
self.provinceId = [[dict objectForKey:@"id"]stringValue];
self.name = [dict objectForKey:@"name"];
self.cities = [NSMutableDictionary dictionary];
NSArray *cityArray = [dict objectForKey:@"citys"];
for (NSDictionary *cityDic in cityArray) {
for (NSString *key in cityDic.allKeys) {
[self.cities setObject:[cityDic objectForKey:key] forKey:key];
}
}
}
return self;
}
//===========================================================
// Keyed Archiving
//
//===========================================================
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:self.name forKey:@"name"];
[encoder encodeObject:self.provinceId forKey:@"provinceId"];
[encoder encodeObject:self.cities forKey:@"cities"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if (self) {
self.name = [decoder decodeObjectForKey:@"name"];
self.provinceId = [decoder decodeObjectForKey:@"provinceId"];
self.cities = [decoder decodeObjectForKey:@"cities"];
}
return self;
}
//===========================================================
// dealloc
//===========================================================
- (void)dealloc
{
[_name release];
[_provinceId release];
[_cities release];
[super dealloc];
}
@end