小编Bre*_*ett的帖子

在Predicate Statement和Float之间使用时崩溃

所以我在我的核心数据中搜索当前地图经度和纬度内的项目.每次我运行声明它都会崩溃.

代码:

    NSError *error = nil;
    NSFetchRequest *boutiqueRequest = [[NSFetchRequest alloc] init];
    NSPredicate *predicateToRun = nil;

    [boutiqueRequest setEntity:[NSEntityDescription entityForName:@"Boutique" inManagedObjectContext:managedObjectContext]];

NSLog(@"NE Longitude: %f", [neCoordLong floatValue]);
NSLog(@"NE Latitude: %f", [neCoordLat floatValue]);
    NSLog(@"SW Longitude: %f", [swCoordLong floatValue]);
    NSLog(@"SW Latitude: %f", [swCoordLat floatValue]);
    NSPredicate *longPredicate = [NSPredicate predicateWithFormat: @"longitude BETWEEN %@", [NSArray arrayWithObjects:neCoordLong, swCoordLong, nil]];
    NSPredicate *latPredicate = [NSPredicate predicateWithFormat: @"latitude BETWEEN %@", [NSArray arrayWithObjects:neCoordLat, swCoordLat, nil]];
    predicateToRun = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:longPredicate, latPredicate, nil]];

    [boutiqueRequest setPredicate:predicateToRun];
    NSLog(@"%@", [boutiqueRequest predicate]);
    NSArray *results = [managedObjectContext …
Run Code Online (Sandbox Code Playgroud)

iphone floating-point predicate core-data

2
推荐指数
1
解决办法
1484
查看次数

标签 统计

core-data ×1

floating-point ×1

iphone ×1

predicate ×1