// // FKAddressListViewModel.m // FirstLink // // Created by ascii on 15/12/7. // Copyright © 2015年 FirstLink. All rights reserved. // #import "FKAddressListViewModel.h" #import "ShipAddress.h" int const FKAddressListRequestAll = 1; int const FKAddressListRequestDelete = 2; int const FKAddressListRequestDefault = 3; @implementation FKAddressListViewModel + (NSString *)navigationTitle:(FKAddressListControllerType)contollerType { if (contollerType == FKAddressListControllerTypeManage) { return @"管理收货地址"; } if ( contollerType == FKAddressListControllerTypeChoice) { return @"选择收货地址"; } return @""; } + (NSString *)rightNaviItemTitle:(FKAddressListControllerType)contollerType { if (contollerType == FKAddressListControllerTypeManage) { return @"添加"; } if ( contollerType == FKAddressListControllerTypeChoice) { return @"管理"; } return @""; } - (ShipAddress *)itemAtIndex:(NSInteger)index { if (index < self.addressListArray.count) { return self.addressListArray[index]; } return nil; } - (void)setAddressSelected:(NSString *)addressID { if (addressID.length > 0) { [self.addressListArray enumerateObjectsUsingBlock:^(ShipAddress *obj, NSUInteger idx, BOOL *stop) { if ([obj.addressID isEqualToString:addressID]) { obj.isSelected = YES; *stop = YES; } else { obj.isSelected = NO; } }]; } } @end