fixed issue with apps duplicating in app list

This commit is contained in:
Diego Waxemberg
2015-07-11 18:47:05 -07:00
parent 8f12114a56
commit 9c6b718be2
6 changed files with 18 additions and 12 deletions
+2 -1
View File
@@ -19,9 +19,10 @@
- (void) saveSettingsWithBitrate:(NSInteger)bitrate framerate:(NSInteger)framerate height:(NSInteger)height width:(NSInteger)width onscreenControls:(NSInteger)onscreenControls;
- (Settings*) retrieveSettings;
- (NSArray*) retrieveHosts;
- (void) saveHosts;
- (void) saveData;
- (Host*) createHost;
- (void) removeHost:(Host*)host;
- (App*) createApp;
- (void) removeApp:(App*)app;
@end
+6 -2
View File
@@ -53,10 +53,10 @@
- (void) removeHost:(Host*)host {
[[self.appDelegate managedObjectContext] deleteObject:host];
[self saveHosts];
[self saveData];
}
- (void) saveHosts {
- (void) saveData {
NSError* error;
if (![[self.appDelegate managedObjectContext] save:&error]) {
Log(LOG_E, @"Unable to save hosts to database: %@", error);
@@ -73,6 +73,10 @@
return [[App alloc] initWithEntity:entity insertIntoManagedObjectContext:[self.appDelegate managedObjectContext]];
}
- (void) removeApp:(App*)app {
[[self.appDelegate managedObjectContext] deleteObject:app];
}
- (NSArray*) fetchRecords:(NSString*)entityName {
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription* entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:[self.appDelegate managedObjectContext]];