过滤两个数组一个是NSArray(核心数据),另一个是NSMutableArray(简单)

时间:2015-05-12 09:33:26

标签: ios objective-c arrays

我将核心数据输入到一个由一些记录组成的数组中并获得位置距离(2.5 km)示例所以我必须使用距离过滤这两个数组

这是我现在正在做的代码

地点......

locaFilterArray = [[NSMutableArray alloc]init];
for (int l = 0 ; l < dealArray.count; l++) {
    Deal * deal = (Deal *)dealArray[l];
    NSArray * locArray = [[deal locationRelation]allObjects];
    double minValue = 10000;
    if (locArray.count > 0) {
        for (int l = 0; l < locArray.count ; l++) {
            DealLocation * location = (DealLocation *)locArray[l];
            double latitude = [[location latitude]doubleValue];
            double longitude = [[location longitude]doubleValue];
            CLLocation * cdLocation = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
            CLLocation * currLocation = [[CLLocation alloc]initWithLatitude:appDelegate.currentLatitude longitude:appDelegate.currentLongitude];
            CLLocationDistance distance = [currLocation distanceFromLocation:cdLotion]/1000;
            if (distance < minValue) {
                minValue = distance;
            }
        }
    } else {
        minValue = 5;
    }
    NSString * value = [NSString stringWithFormat:@"%.1f",minValue];
    [locaFilterArray addObject:value];
}
NSLog(@"%lu",(unsigned long)locaFilterArray.count);

这样就像这样打印/// 2.5,1.2,18.3,4.5 ....就像这样

并且从核心数据获取日期所以这两个数组之间没有关系,但我必须在表视图中按升序过滤此核心数据数据

任何帮助都会得到很大的赞赏...... :)。

0 个答案:

没有答案