aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2014-01-13 16:00:15 +0000
committerStuart Connolly <stuart02@gmail.com>2014-01-13 16:00:15 +0000
commit34983d4ab09107c3f4d4d53cc0d39b9fd35c22fb (patch)
treef22f4ee39fc05711c429e2a23ec6d63863d456bb /Source
parent605bdb86dffeaf792b730a2489dbb33785e9e43d (diff)
downloadsequelpro-34983d4ab09107c3f4d4d53cc0d39b9fd35c22fb.tar.gz
sequelpro-34983d4ab09107c3f4d4d53cc0d39b9fd35c22fb.tar.bz2
sequelpro-34983d4ab09107c3f4d4d53cc0d39b9fd35c22fb.zip
Stop spamming the console.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFavoriteColorSupport.h7
-rw-r--r--Source/SPFavoriteColorSupport.m26
2 files changed, 20 insertions, 13 deletions
diff --git a/Source/SPFavoriteColorSupport.h b/Source/SPFavoriteColorSupport.h
index ad35b80d..0d690922 100644
--- a/Source/SPFavoriteColorSupport.h
+++ b/Source/SPFavoriteColorSupport.h
@@ -32,7 +32,8 @@
#import <Foundation/Foundation.h>
-@interface SPFavoriteColorSupport : NSObject {
+@interface SPFavoriteColorSupport : NSObject
+{
NSUserDefaults *prefs;
}
@@ -43,19 +44,23 @@
/**
* Get the default list of colors supplied by Sequel Pro.
+ *
* @return An array with NSColor * items.
*/
+ (NSArray *)defaultColorList;
/**
* Get the current color for a specific index.
+ *
* @return The color or nil if colorIndex was < 0 or the index was not defined.
*/
- (NSColor *)colorForIndex:(NSInteger)colorIndex;
/**
* The current list of colors from user prefs.
+ *
* @return An array with NSColor * items.
*/
- (NSArray *)userColorList;
+
@end
diff --git a/Source/SPFavoriteColorSupport.m b/Source/SPFavoriteColorSupport.m
index 10519791..0c10ef28 100644
--- a/Source/SPFavoriteColorSupport.m
+++ b/Source/SPFavoriteColorSupport.m
@@ -34,23 +34,24 @@
@implementation SPFavoriteColorSupport
-static SPFavoriteColorSupport *ColorSupport = nil;
+static SPFavoriteColorSupport *_colorSupport = nil;
- (id)init
{
- self = [super init];
- if (self) {
+ if ((self = [super init])) {
prefs = [NSUserDefaults standardUserDefaults];
}
+
return self;
}
+ (SPFavoriteColorSupport *)sharedInstance
{
- if(!ColorSupport)
- ColorSupport = [[self allocWithZone:NULL] init];
+ if (!_colorSupport) {
+ _colorSupport = [[self allocWithZone:NULL] init];
+ }
- return ColorSupport;
+ return _colorSupport;
}
@@ -67,26 +68,27 @@ static SPFavoriteColorSupport *ColorSupport = nil;
nil];
}
-
- (NSColor *)colorForIndex:(NSInteger)colorIndex
{
NSArray *colorList = [self userColorList];
- //check bounds
- if(colorIndex < 0 || (NSUInteger)colorIndex >= [colorList count]) {
- NSLog(@"%s: Requesting color index %ld, but only have %lu items. Returning nil.",__PRETTY_FUNCTION__,(long)colorIndex,(unsigned long)[colorList count]);
+
+ // Check bounds
+ if (colorIndex < 0 || (NSUInteger)colorIndex >= [colorList count]) {
return nil;
}
return [colorList objectAtIndex:colorIndex];
}
-
- (NSArray *)userColorList
{
NSArray *archivedColors = [prefs objectForKey:SPFavoriteColorList];
NSMutableArray *colorList = [NSMutableArray arrayWithCapacity:[archivedColors count]];
- for (NSData *archivedColor in archivedColors) {
+
+ for (NSData *archivedColor in archivedColors)
+ {
NSColor *color = [NSUnarchiver unarchiveObjectWithData:archivedColor];
+
[colorList addObject:color];
}