-
Notifications
You must be signed in to change notification settings - Fork 5
/
PreferencesController.m
58 lines (44 loc) · 1.48 KB
/
PreferencesController.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
//
// preferencesController.m
// FriendFeed
//
// Created by Nicolas Rolland on 1/18/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "preferencesController.h"
NSString * const FFSettingsChanged = @"settingsChanged";
NSString * const FFUserName = @"userName";
NSString * const FFRemoteKey = @"remoteKey";
@implementation PreferencesController
- (id)init
{
if (self = [super initWithNibName:@"settings"bundle:nil]) {
// Initialize your view controller.
self.title = @"Settings";
self.tabBarItem.image = [UIImage imageNamed:@"toolbar_settings.png"];
}
return self;
}
-(void)viewDidLoad{
NSLog(@"View did load");
[userNameField setText:[[NSUserDefaults standardUserDefaults] valueForKey:FFUserName]];
[remoteKeyField setText: [[NSUserDefaults standardUserDefaults] valueForKey:FFRemoteKey]];
[userNameField setDelegate:self];
[remoteKeyField setDelegate:self];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
- (IBAction) deactivateBothFields:(id)sender {
[[NSUserDefaults standardUserDefaults] setValue:[userNameField text] forKey:FFUserName];
[[NSUserDefaults standardUserDefaults] setValue:[remoteKeyField text] forKey:FFRemoteKey];
[userNameField resignFirstResponder];
[remoteKeyField resignFirstResponder];
}
-(void)viewWillDisappear:(BOOL)animated
{
NSLog(@"view will disappear");
[[NSNotificationCenter defaultCenter] postNotificationName:FFSettingsChanged object:nil];
}
@end