【发布时间】:2014-07-25 19:41:37
【问题描述】:
我有一个 UITableView,我从服务器获取信息,我想根据修改日期对我的信息进行排序,请你帮我完成这个实现,我该如何排序?
提前致谢!感谢答案部分的任何代码!
我从 json 修改的日期是这样的
"dateModified": "2014-06-23T07:51:08.373Z"
我的 ViewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
_mapView.showsUserLocation = YES;
_mapView.delegate = self;
[ApiManager fetchCoordinates:^(id result) {
newAnnotations = [NSMutableArray array];
CLLocationCoordinate2D location;
NSArray *array=(NSArray*)result;
for (NSDictionary *dictionary in array)
{
MyAnnotation *newAnnotation;
newAnnotation = [[MyAnnotation alloc] init];
newAnnotation.company = dictionary[@"company"];
newAnnotation.dateModified = dictionary[@"dateModified"];
[newAnnotations addObject:newAnnotation];
}
[self.mapView addAnnotations:newAnnotations];
} failure:^(NSError *error) {
}];
}
我的表格视图控制器
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:simpleTableIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:simpleTableIdentifier];
MyAnnotation *newAnnotation=[newAnnotations objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@",newAnnotation.company];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",newAnnotation.dateModified];
return cell;
}
【问题讨论】:
标签: ios objective-c uitableview sorting nsmutablearray