aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPQueryFavoriteManager.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-12-13 19:48:41 +0100
committerMax <post@wickenrode.com>2014-12-13 19:48:41 +0100
commit3b251b8e3d4dc9a694ef76562b388ab07da54785 (patch)
tree8ce5a4c4c637bab883ed7e6667bff7b5b74adbc3 /Source/SPQueryFavoriteManager.m
parent876dde21d97897ad4ee98aa0d6b11898282982ce (diff)
downloadsequelpro-3b251b8e3d4dc9a694ef76562b388ab07da54785.tar.gz
sequelpro-3b251b8e3d4dc9a694ef76562b388ab07da54785.tar.bz2
sequelpro-3b251b8e3d4dc9a694ef76562b388ab07da54785.zip
Replace some NSDictionaries with literals
* [NSDictionary dictionary] → @{} * [NSDictionary dictionaryWithObject:forKey:] can safely be replaced. object==nil would have already thrown a NPE in the past. * Also replaced some (hopefully safe) NSArray initializers (ie. their objects should always exist).
Diffstat (limited to 'Source/SPQueryFavoriteManager.m')
-rw-r--r--Source/SPQueryFavoriteManager.m50
1 files changed, 24 insertions, 26 deletions
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 38758a45..649d4b5a 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -43,8 +43,6 @@
#define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]")
#define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]")
-#define SP_Int(x) [NSNumber numberWithInteger:x]
-
@interface SPQueryFavoriteManager ()
- (void)_initWithNoSelection;
@@ -86,11 +84,11 @@
- (void)awakeFromNib
{
#ifndef SP_CODA
- [favorites addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- @"Global", @"name",
- @"", @"headerOfFileURL",
- @"", @"query",
- nil]];
+ [favorites addObject:@{
+ @"name" : @"Global",
+ @"headerOfFileURL" : @"",
+ @"query" : @""
+ }];
// Set up the split view
[favoritesSplitView setMinSize:152.f ofSubviewAtIndex:0];
@@ -206,7 +204,7 @@
favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[[favoriteNameTextField stringValue] stringByAppendingFormat:@" Copy"], [favoriteQueryTextView string], nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]];
// Add a new favorite
else
- favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Favorite", @"", nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]];
+ favorite = [NSMutableDictionary dictionaryWithObjects:@[@"New Favorite", @""] forKeys:@[@"name", @"query"]];
// If a favourite is currently selected, add the new favourite next to it
if ([favoritesTableView numberOfSelectedRows] > 0) {
@@ -380,24 +378,24 @@
{
// Look up the sender's tag to determine the placeholder to insert.
// Note that tag values alter behaviour slightly - see below.
- NSDictionary *lookupTable = [NSDictionary dictionaryWithObjectsAndKeys:
- NSLocalizedString(@"default_value", @"Query snippet default value placeholder"), SP_Int(100),
- NSLocalizedString(@"$(shell_command)", @"Query snippet shell command syntax and placeholder"), SP_Int(101),
- @"$1", SP_Int(501),
- @"¦a¦b¦", SP_Int(102),
- @"¦¦a¦b¦¦", SP_Int(103),
- @"¦", SP_Int(104),
- @"$SP_SELECTED_TABLE", SP_Int(105),
- @"$SP_SELECTED_TABLES", SP_Int(106),
- @"$SP_SELECTED_DATABASE", SP_Int(107),
- @"¦$SP_ASLIST_ALL_FIELDS¦", SP_Int(108),
- @"¦¦$SP_ASLIST_ALL_FIELDS¦¦", SP_Int(109),
- @"¦$SP_ASLIST_ALL_TABLES¦", SP_Int(110),
- @"¦¦$SP_ASLIST_ALL_TABLES¦¦", SP_Int(111),
- @"¦$SP_ASLIST_ALL_DATABASES¦", SP_Int(112),
- @"¦¦$SP_ASLIST_ALL_DATABASES¦¦", SP_Int(113),
- nil];
- NSString *placeholder = [lookupTable objectForKey:SP_Int([[sender selectedItem] tag])];
+ NSDictionary *lookupTable = @{
+ @100 : NSLocalizedString(@"default_value", @"Query snippet default value placeholder"),
+ @101 : NSLocalizedString(@"$(shell_command)", @"Query snippet shell command syntax and placeholder"),
+ @501 : @"$1",
+ @102 : @"¦a¦b¦",
+ @103 : @"¦¦a¦b¦¦",
+ @104 : @"¦",
+ @105 : @"$SP_SELECTED_TABLE",
+ @106 : @"$SP_SELECTED_TABLES",
+ @107 : @"$SP_SELECTED_DATABASE",
+ @108 : @"¦$SP_ASLIST_ALL_FIELDS¦",
+ @109 : @"¦¦$SP_ASLIST_ALL_FIELDS¦¦",
+ @110 : @"¦$SP_ASLIST_ALL_TABLES¦",
+ @111 : @"¦¦$SP_ASLIST_ALL_TABLES¦¦",
+ @112 : @"¦$SP_ASLIST_ALL_DATABASES¦",
+ @113 : @"¦¦$SP_ASLIST_ALL_DATABASES¦¦"
+ };
+ NSString *placeholder = [lookupTable objectForKey:[NSNumber numberWithInteger:[[sender selectedItem] tag]]];
if (!placeholder) [NSException raise:NSInternalInconsistencyException format:@"Inserted placeholder (%lld) not found", (long long)[[sender selectedItem] tag]];
// Iterate through the current snippets, to get the lowest unused tab counter, and