From f209670c1abdbce18ad64e4044cd41319d4ffc7b Mon Sep 17 00:00:00 2001 From: Diego Waxemberg Date: Thu, 1 Jan 2015 23:40:52 -0500 Subject: [PATCH] now remove host from database when the user removes it --- Limelight/Database/DataManager.h | 1 + Limelight/Database/DataManager.m | 4 ++++ Limelight/ViewControllers/MainFrameViewController.m | 2 ++ 3 files changed, 7 insertions(+) diff --git a/Limelight/Database/DataManager.h b/Limelight/Database/DataManager.h index fc4e005f..812a9e18 100644 --- a/Limelight/Database/DataManager.h +++ b/Limelight/Database/DataManager.h @@ -20,5 +20,6 @@ - (NSArray*) retrieveHosts; - (void) saveHosts; - (Host*) createHost; +- (void) removeHost:(Host*)host; @end diff --git a/Limelight/Database/DataManager.m b/Limelight/Database/DataManager.m index 39ec1969..274df545 100644 --- a/Limelight/Database/DataManager.m +++ b/Limelight/Database/DataManager.m @@ -51,6 +51,10 @@ return host; } +- (void) removeHost:(Host*)host { + [[self.appDelegate managedObjectContext] deleteObject:host]; +} + - (void) saveHosts { NSError* error; if (![[self.appDelegate managedObjectContext] save:&error]) { diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 036ada89..2f5417d0 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -124,6 +124,8 @@ static StreamConfiguration* streamConfig; [longClickAlert addAction:[UIAlertAction actionWithTitle:@"Remove Host" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action) { [hostList removeObject:host]; [_discMan removeHostFromDiscovery:host]; + DataManager* dataMan = [[DataManager alloc] init]; + [dataMan removeHost:host]; }]]; [longClickAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [self presentViewController:longClickAlert animated:YES completion:^{