所以我在我的核心数据中搜索当前地图经度和纬度内的项目.每次我运行声明它都会崩溃.
代码:
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)