forked from KosmicTask/Fragaria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MGSFragariaPrefsViewController.m
57 lines (41 loc) · 1.06 KB
/
MGSFragariaPrefsViewController.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
//
// MGSFragariaPrefsViewController.m
// Fragaria
//
// Created by Jonathan on 22/10/2012.
//
//
#import "MGSFragariaPrefsViewController.h"
@interface MGSFragariaPrefsViewController ()
@end
@implementation MGSFragariaPrefsViewController
/*
- commitEditingAndDiscard:
*/
- (BOOL)commitEditingAndDiscard:(BOOL)discard
{
BOOL commit = YES;
// commit edits, discarding changes on error
if (![[NSUserDefaultsController sharedUserDefaultsController] commitEditing]) {
if (discard) [[NSUserDefaultsController sharedUserDefaultsController] discardEditing];
commit = NO;
}
return commit;
}
#pragma mark -
#pragma mark NSTabViewDelegate
/*
- tabView:shouldSelectTabViewItem:
*/
- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
#pragma unused(tabView)
#pragma unused(tabViewItem)
BOOL select = YES;
// if we have un committed edits then disallow tab item selection
if (![self commitEditingAndDiscard:NO]) {
select = NO;
}
return select;
}
@end