now remove host from database when the user removes it

This commit is contained in:
Diego Waxemberg
2015-01-01 23:40:52 -05:00
parent 168eac17eb
commit f209670c1a
3 changed files with 7 additions and 0 deletions

View File

@@ -20,5 +20,6 @@
- (NSArray*) retrieveHosts;
- (void) saveHosts;
- (Host*) createHost;
- (void) removeHost:(Host*)host;
@end

View File

@@ -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]) {

View File

@@ -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:^{