Commit 6e376241 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

LAN server sync: fix previous commit

parent e7ad674a
......@@ -76,6 +76,11 @@
self.edgesForExtendedLayout = UIRectEdgeNone;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
......@@ -97,6 +102,12 @@
[self protocolSelectionChanged:nil];
}
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(ubiquitousKeyValueStoreDidChange:)
name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
object:[NSUbiquitousKeyValueStore defaultStore]];
NSUbiquitousKeyValueStore *ukvStore = [NSUbiquitousKeyValueStore defaultStore];
[ukvStore synchronize];
_serverList = [NSMutableArray arrayWithArray:[ukvStore arrayForKey:kVLCStoredServerList]];
......@@ -137,8 +148,16 @@
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:_serverList forKey:kVLCStoredServerList];
NSUbiquitousKeyValueStore *ukvStore = [NSUbiquitousKeyValueStore defaultStore];
[ukvStore setArray:_serverList forKey:kVLCStoredServerList];
[ukvStore synchronize];
}
- (void)ubiquitousKeyValueStoreDidChange:(NSNotification *)notification
{
/* TODO: don't blindly trust that the Cloud knows best */
_serverList = [NSMutableArray arrayWithArray:[[NSUbiquitousKeyValueStore defaultStore] arrayForKey:kVLCStoredServerList]];
[self.storedServersTableView reloadData];
}
- (IBAction)connectToServer:(id)sender
......
......@@ -57,7 +57,6 @@
[super viewDidLoad];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(ubiquitousKeyValueStoreDidChange:)
name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment