-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGeoInfo.m
More file actions
executable file
·48 lines (42 loc) · 1.2 KB
/
Copy pathGeoInfo.m
File metadata and controls
executable file
·48 lines (42 loc) · 1.2 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
//
// Geo.m
// ZhiWeiboPhone
//
// Created by junmin liu on 12-9-5.
// Copyright (c) 2012年 idfsoft. All rights reserved.
//
#import "GeoInfo.h"
@implementation GeoInfo
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;
- (id)initWithJsonDictionary:(NSDictionary*)dic
{
self = [super init];
if (self) {
NSArray *coordinatesArray = [dic arrayValueForKey:@"coordinates"];
if (coordinatesArray && coordinatesArray.count == 2) {
self.latitude = [[coordinatesArray objectAtIndex:0] doubleValue];
self.longitude = [[coordinatesArray objectAtIndex:1] doubleValue];
}
}
return self;
}
//===========================================================
// Keyed Archiving
//
//===========================================================
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeDouble:self.latitude forKey:@"latitude"];
[encoder encodeDouble:self.longitude forKey:@"longitude"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if (self) {
self.latitude = [decoder decodeDoubleForKey:@"latitude"];
self.longitude = [decoder decodeDoubleForKey:@"longitude"];
}
return self;
}
@end