This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ViewController.m
68 lines (53 loc) · 2.09 KB
/
ViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// ViewController.m
// RemoteConfig
//
// Created by Kevin Renskers on 24-05-12.
// Copyright (c) 2012 Gangverk. All rights reserved.
//
#import "ViewController.h"
#import "Config.h"
NSString *const GVRemoteConfigStatusStrings[] = {
@"Using defaults\n",
@"Using locally saved config\n",
@"Downloading\n",
@"Download failed\n",
@"Using remote config\n"
};
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *integerLabel;
@property (weak, nonatomic) IBOutlet UILabel *stringLabel;
@property (weak, nonatomic) IBOutlet UITextView *statusLabel;
@property (weak, nonatomic) IBOutlet UILabel *nonExistingLabel;
- (IBAction)refreshLabels;
- (IBAction)forceDownload;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusChanged:) name:GVRemoteConfigStatusChangedNotification object:nil];
self.integerLabel.text = [NSString stringWithFormat:@"%@", [Config sharedInstance].exampleIntegerValue];
self.stringLabel.text = [Config sharedInstance].exampleStringValue;
self.nonExistingLabel.text = [Config sharedInstance].nonExistingStringValue;
}
- (void)viewDidUnload {
[[NSNotificationCenter defaultCenter] removeObserver:self name:GVRemoteConfigStatusChangedNotification object:nil];
[self setIntegerLabel:nil];
[self setStatusLabel:nil];
[self setStringLabel:nil];
[self setNonExistingLabel:nil];
[super viewDidUnload];
}
- (IBAction)refreshLabels {
self.integerLabel.text = [NSString stringWithFormat:@"%@", [Config sharedInstance].exampleIntegerValue];
self.stringLabel.text = [Config sharedInstance].exampleStringValue;
self.nonExistingLabel.text = [Config sharedInstance].nonExistingStringValue;
}
- (IBAction)forceDownload {
[[Config sharedInstance] downloadRemoteFile];
}
- (void)statusChanged:(NSNotification *)notification {
Config *config = notification.object;
self.statusLabel.text = [self.statusLabel.text stringByAppendingString:GVRemoteConfigStatusStrings[config.GVRemoteConfigStatus]];
}
@end