PickerAddressModel.m 1.91 KB
Newer Older
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 81
//
//  PickerAddressModel.m
//  MOFSPickerManager
//
//  Created by lzqhoh@163.com on 16/8/31.
//  Copyright © 2016年 luoyuan. All rights reserved.
//

#import "PickerAddressModel.h"

@implementation PickerAddressModel

- (NSMutableArray *)list {
    if (!_list) {
        _list = [NSMutableArray array];
    }
    return _list;
}

- (instancetype)initWithXML:(GDataXMLElement *)xml {
    self.name = [[xml attributeForName:@"name"] stringValue];
    if ([xml attributeForName:@"zipcode"]) {
        self.zipcode = [[xml attributeForName:@"zipcode"] stringValue];
    }
    @try {
        NSArray *arr = [xml nodesForXPath:@"city" error:nil];
        for (int i = 0 ; i < arr.count ; i++ ) {
            CityModel *model = [[CityModel alloc] initWithXML:arr[i]];
            [self.list addObject:model];
        }
    } @catch (NSException *exception) {
        
    } @finally {
        
    }
    return self;
}

@end

@implementation CityModel

- (NSMutableArray *)list {
    if (!_list) {
        _list = [NSMutableArray array];
    }
    return _list;
}

- (instancetype)initWithXML:(GDataXMLElement *)xml {
    self.name = [[xml attributeForName:@"name"] stringValue];
    if ([xml attributeForName:@"zipcode"]) {
        self.zipcode = [[xml attributeForName:@"zipcode"] stringValue];
    }
    @try {
        NSArray *arr = [xml nodesForXPath:@"district" error:nil];
        for (int i = 0 ; i < arr.count ; i++ ) {
            DistrictModel *model = [[DistrictModel alloc] initWithXML:arr[i]];
            [self.list addObject:model];
        }
    } @catch (NSException *exception) {
        
    } @finally {
        
    }
    return self;
}

@end

@implementation DistrictModel

- (instancetype)initWithXML:(GDataXMLElement *)xml {
    self.name = [[xml attributeForName:@"name"] stringValue];
    if ([xml attributeForName:@"zipcode"]) {
        self.zipcode = [[xml attributeForName:@"zipcode"] stringValue];
    }
    return self;
}

@end