Skip to content

Instantly share code, notes, and snippets.

@alexfish
Created July 20, 2011 15:03
Show Gist options
  • Save alexfish/1095129 to your computer and use it in GitHub Desktop.
Save alexfish/1095129 to your computer and use it in GitHub Desktop.
-(void)loadVisiblePlaces {
NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];
//printf("Starting visible allPlaces");
[[appDelegate filteredPlaces] removeAllObjects];
if ([prefs filterOn]==NO) {
for (Place *p in [appDelegate allPlaces]) {
if(![p.category isEqual:[NSString stringWithFormat:@"Mobile"]]){
[[appDelegate filteredPlaces] addObject:p];
}
}
} else {
NSString *selected = [prefs returnSelectedItems];
BOOL *openFilter = [prefs openOption];
NSArray *cats = [selected componentsSeparatedByString: @"|"];
//NSLog(@"cats is:%@",cats);
//NSMutableArray *englishDays = [NSMutableArray arrayWithObjects:@"",@"Sunday",@"Monday",@"Tuesday",@"Wednesday",@"Thursday",@"Friday",@"Saturday",nil];
//NSLog(@"today:%i",weekday);
for (Place *a_place in [appDelegate allPlaces]){
[[mapView viewForAnnotation:a_place.annotation] setHidden:YES];
//NSLog(@"status:%d",openStatus);
for(NSArray *a_cat in cats){
NSPredicate *cat_pred = [NSPredicate predicateWithFormat:@"SELF contains %@",a_cat];
BOOL result = [cat_pred evaluateWithObject:a_place.category];
if(result){
BOOL *openStatus = [self openStatus:a_place];
if(openFilter == YES){
if(openStatus == YES){
//NSLog(@"adding open shop");
[[appDelegate filteredPlaces] addObject:a_place];
[[mapView viewForAnnotation:a_place.annotation] setHidden:NO];
}
} else {
//NSLog(@"adding all by cat");
[[appDelegate filteredPlaces] addObject:a_place];
[[mapView viewForAnnotation:a_place.annotation] setHidden:NO];
}
}
}
}
}
[[appDelegate filteredPlaces] sortUsingSelector:@selector(comparePlace:)];
//[[appDelegate filteredPlaces] removeObjectsInRange:NSMakeRange(0,4)];
//NSLog(@"places are:%@",[appDelegate filteredPlaces]);
[tableView reloadData];
[self updateNearest];
//NSLog(@"Ending visible allPlaces");
[pool2 release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment