Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

made bookmark button disabled if bookmark already exists

  • Loading branch information...
commit debd09090aecb77f7371497a338b4bed40793168 1 parent 2097f8e
@cozmoboy cozmoboy authored
View
2  MappingMashupApp/APIManager.m
@@ -142,7 +142,7 @@ - (NSMutableArray*)createVenuesArray:(NSArray *)jsonArray
currentVenue.longitude =[[ business valueForKey:@"longitude"] floatValue];
currentVenue.latitude = [[business valueForKey:@"latitude"] floatValue];
currentVenue.photoTitle = [business valueForKey:@"title"];
- currentVenue.phone = [business valueForKey:@"phone"];
+ currentVenue.phone = [business valueForKey:@"address1"];
[yelpVenuesArray addObject:currentVenue];
View
2  MappingMashupApp/BookmarksViewController.m
@@ -91,7 +91,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
Business *currentBusiness = [bookmarkArray objectAtIndex:[indexPath row]];
currentCell.textLabel.text = currentBusiness.name;
- currentCell.detailTextLabel.text = currentBusiness.yelpURLString;
+ currentCell.detailTextLabel.text = currentBusiness.phone;
return currentCell;
}
View
2  MappingMashupApp/HistoryViewController.m
@@ -85,7 +85,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
Business *currentBusiness = [historyArray objectAtIndex:[indexPath row] ];
currentCell.textLabel.text = currentBusiness.name;
- currentCell.detailTextLabel.text = currentBusiness.yelpURLString;
+ currentCell.detailTextLabel.text = currentBusiness.phone;
return currentCell;
}
View
32 MappingMashupApp/YelpWebPageBrowser.m
@@ -60,7 +60,7 @@ - (void)viewDidLoad
//Enable button just in case
[self.navigationItem.rightBarButtonItem setEnabled:YES];
-
+ [self fetchToSeeIfCurrentBusinessIsBookmarkedAndSetButtonDisabled];
//Check to see if this venue is already bookmarked
// if (venue.isBookmarked == YES)
// {
@@ -106,6 +106,36 @@ - (void)viewDidLoad
}
+-(void)fetchToSeeIfCurrentBusinessIsBookmarkedAndSetButtonDisabled
+{
+
+ NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"BookmarkedBusiness" inManagedObjectContext:self.managedObjectContext];
+ NSFetchRequest * fetchRequest = [[NSFetchRequest alloc]init];
+ NSFetchedResultsController * fetchResultsController;
+
+ //Now customize your search! We'd want to switch this to see if isBookmarked == true
+ NSArray * sortDescriptors = [[NSArray alloc] initWithObjects:nil];
+ NSPredicate * predicate = [NSPredicate predicateWithFormat:@"yelpURLString == %@", yelpURLString];
+ NSError *searchError;
+
+ //Lock and load
+ [fetchRequest setSortDescriptors:sortDescriptors];
+ [fetchRequest setPredicate:predicate];
+ [fetchRequest setEntity:entityDescription];
+ fetchResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
+
+ [fetchResultsController performFetch:&searchError];
+
+ NSLog(@"------ fetchresults Array: %@", fetchResultsController.fetchedObjects);
+
+ if ([fetchResultsController.fetchedObjects count] > 0) {
+ [self.navigationItem.rightBarButtonItem setEnabled: NO];
+ }
+
+}
+
+
+
-(void) addBookmark
{
Please sign in to comment.
Something went wrong with that request. Please try again.