aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMCopyTable.m4
-rw-r--r--Source/CMMCPConnection.h6
-rw-r--r--Source/CMMCPConnection.m26
-rw-r--r--Source/CMMCPResult.m3
-rw-r--r--Source/CMTextView.m11
-rw-r--r--Source/CustomQuery.m21
-rw-r--r--Source/NoodleLineNumberView.m7
-rw-r--r--Source/SPArrayAdditions.h9
-rw-r--r--Source/SPExportController.m7
-rw-r--r--Source/SPNarrowDownCompletion.m5
-rw-r--r--Source/SPQueryConsole.m3
-rw-r--r--Source/SPTableData.m54
-rw-r--r--Source/TableContent.m42
-rw-r--r--Source/TableDocument.m5
-rw-r--r--Source/TableDump.m69
-rw-r--r--Source/TablesList.m17
16 files changed, 164 insertions, 125 deletions
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index 2f7bb929..85f8a20e 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -101,7 +101,7 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
if(withHeaders) {
int i;
for( i = 0; i < numColumns; i++ ){
- [result appendString:[NSString stringWithFormat:@"%@\t", [[[columns objectAtIndex:i] headerCell] stringValue]]];
+ [result appendString:[NSString stringWithFormat:@"%@\t", [[NSArrayObjectAtIndex(columns, i) headerCell] stringValue]]];
}
[result appendString:[NSString stringWithFormat:@"\n"]];
}
@@ -119,7 +119,7 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
rowData = nil;
for ( c = 0; c < numColumns; c++)
{
- col = [columns objectAtIndex:c];
+ col = NSArrayObjectAtIndex(columns, c);
rowData = [dataSource tableView:self
objectValueForTableColumn:col
row:[row intValue] ];
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h
index 4005c19b..81b25535 100644
--- a/Source/CMMCPConnection.h
+++ b/Source/CMMCPConnection.h
@@ -78,7 +78,13 @@
IMP cStringPtr;
IMP willQueryStringPtr;
+ IMP stopKeepAliveTimerPtr;
+ IMP startKeepAliveTimerResettingStatePtr;
+ SEL cStringSEL;
+ SEL willQueryStringSEL;
+ SEL stopKeepAliveTimerSEL;
+ SEL startKeepAliveTimerResettingStateSEL;
}
- (id) init;
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 4cc2fccf..3101beb9 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -140,7 +140,14 @@ static void forcePingTimeout(int signalNumber);
NSLog(@"Connection error dialog could not be loaded; connection failure handling will not function correctly.");
}
- cStringPtr = [self methodForSelector:@selector(cStringFromString:usingEncoding:)];
+ willQueryStringSEL = @selector(willQueryString:);
+ stopKeepAliveTimerSEL = @selector(stopKeepAliveTimer);
+ startKeepAliveTimerResettingStateSEL = @selector(startKeepAliveTimerResettingState:);
+ cStringSEL = @selector(cStringFromString:);
+
+ cStringPtr = [self methodForSelector:cStringSEL];
+ stopKeepAliveTimerPtr = [self methodForSelector:stopKeepAliveTimerSEL];
+ startKeepAliveTimerResettingStatePtr = [self methodForSelector:startKeepAliveTimerResettingStateSEL];
}
@@ -740,14 +747,14 @@ static void forcePingTimeout(int signalNumber);
return nil;
}
- [self stopKeepAliveTimer];
+ (void)(*stopKeepAliveTimerPtr)(self, stopKeepAliveTimerSEL);
// queryStartTime = clock();
// Inform the delegate about the query if logging is enabled and
// delegate responds to willQueryString:
if (consoleLoggingEnabled && delegateResponseToWillQueryString)
- (void)(NSString*)(*willQueryStringPtr)(delegate, @selector(willQueryString:), query);
+ (void)(NSString*)(*willQueryStringPtr)(delegate, willQueryStringSEL, query);
// Derive the query string in the correct encoding
switch(encoding) {
@@ -755,7 +762,7 @@ static void forcePingTimeout(int signalNumber);
theCQuery = NSStringUTF8String(query);
break;
default:
- theCQuery = (const char*)(NSString*)(int)(*cStringPtr)(self, @selector(cStringFromString:), query, encoding);
+ theCQuery = (const char*)(NSString*)(int)(*cStringPtr)(self, cStringSEL, query, encoding);
//[self cStringFromString:query usingEncoding:encoding];
}
@@ -864,7 +871,7 @@ static void forcePingTimeout(int signalNumber);
if (queryResultCode & delegateResponseToWillQueryString)
[delegate queryGaveError:lastQueryErrorMessage];
- [self startKeepAliveTimerResettingState:YES];
+ (void)(int)(*startKeepAliveTimerResettingStatePtr)(self, startKeepAliveTimerResettingStateSEL, YES);
if (!theResult) return nil;
return [theResult autorelease];
@@ -950,7 +957,7 @@ static void forcePingTimeout(int signalNumber);
if (delegate && [delegate valueForKey:@"_encoding"]) {
[self queryString:[NSString stringWithFormat:@"/*!40101 SET NAMES '%@' */", [NSString stringWithString:[delegate valueForKey:@"_encoding"]]]];
if (delegate && [delegate respondsToSelector:@selector(connectionEncodingViaLatin1)]) {
- if ([delegate connectionEncodingViaLatin1]) [self queryString:@"/*!40101 SET CHARACTER_SET_RESULTS=latin1 */"];
+ if ([delegate connectionEncodingViaLatin1]) [self queryString:@"/*!40101 SET CHARACTER_SET_RESULTS=latin1 */"];
}
}
}
@@ -958,8 +965,11 @@ static void forcePingTimeout(int signalNumber);
- (void)setDelegate:(id)object
{
delegate = object;
- delegateResponseToWillQueryString = (delegate && [delegate respondsToSelector:@selector(willQueryString:)]);
- willQueryStringPtr = [delegate methodForSelector:@selector(willQueryString:)];
+
+ delegateResponseToWillQueryString = (delegate && [delegate respondsToSelector:willQueryStringSEL]);
+
+ willQueryStringPtr = [delegate methodForSelector:willQueryStringSEL];
+
}
/* Getting the currently used time zone (in communication with the DB server). */
diff --git a/Source/CMMCPResult.m b/Source/CMMCPResult.m
index 701e614c..ebc5c6ab 100644
--- a/Source/CMMCPResult.m
+++ b/Source/CMMCPResult.m
@@ -24,6 +24,7 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "CMMCPResult.h"
+#import "SPArrayAdditions.h"
@implementation CMMCPResult
@@ -295,7 +296,7 @@ modified version for use with sequel-pro
switch (aType) {
case MCPTypeDictionary :
- [theReturn setObject:theCurrentObj forKey:[mNames objectAtIndex:i]];
+ [theReturn setObject:theCurrentObj forKey:NSArrayObjectAtIndex(mNames, i)];
break;
case MCPTypeArray :
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 8e891b20..313a88bc 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -26,6 +26,7 @@
#import "CustomQuery.h"
#import "TableDocument.h"
#import "SPStringAdditions.h"
+#import "SPArrayAdditions.h"
#import "SPTextViewAdditions.h"
#import "SPNarrowDownCompletion.h"
@@ -138,7 +139,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[queryResult dataSeek:0];
for (i = 0 ; i < [queryResult numOfRows] ; i++)
{
- [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:[[queryResult fetchRowAsArray] objectAtIndex:0], @"display", @"table-small-square", @"image", nil]];
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0), @"display", @"table-small-square", @"image", nil]];
//[possibleCompletions addObject:[[queryResult fetchRowAsArray] objectAtIndex:0]];
}
@@ -158,7 +159,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
for (i = 0 ; i < [queryResult numOfRows] ; i++)
{
// [possibleCompletions addObject:[[queryResult fetchRowAsArray] objectAtIndex:0]];
- [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:[[queryResult fetchRowAsArray] objectAtIndex:0], @"display", @"database-small", @"image", nil]];
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0), @"display", @"database-small", @"image", nil]];
}
// Add proc/func only for MySQL version 5 or higher
@@ -170,7 +171,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
for (i = 0 ; i < [queryResult numOfRows] ; i++)
{
// [possibleCompletions addObject:[[queryResult fetchRowAsArray] objectAtIndex:1]];
- [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:[[queryResult fetchRowAsArray] objectAtIndex:1], @"display", @"proc-small", @"image", nil]];
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 1), @"display", @"proc-small", @"image", nil]];
}
// Add all function to completions list for currently selected table
@@ -180,7 +181,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
for (i = 0 ; i < [queryResult numOfRows] ; i++)
{
// [possibleCompletions addObject:[[queryResult fetchRowAsArray] objectAtIndex:1]];
- [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:[[queryResult fetchRowAsArray] objectAtIndex:1], @"display", @"func-small", @"image", nil]];
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 1), @"display", @"func-small", @"image", nil]];
}
}
@@ -988,7 +989,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
for (i = 0; i < [matchingCompletions count]; i++)
{
- NSString* obj = [matchingCompletions objectAtIndex:i];
+ NSString* obj = NSArrayObjectAtIndex(matchingCompletions, i);
if(![compl containsObject:obj])
if ([partialString isEqualToString:[obj substringToIndex:partialLength]])
// Matches case --> Insert at beginning of completion list
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index b59fe084..eab76897 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -28,6 +28,7 @@
#import "SPGrowlController.h"
#import "SPStringAdditions.h"
#import "SPTextViewAdditions.h"
+#import "SPArrayAdditions.h"
#import "TableDocument.h"
#import "TablesList.h"
#import "RegexKitLite.h"
@@ -410,14 +411,16 @@
// Remove all the columns
theColumns = [customQueryView tableColumns];
while ([theColumns count]) {
- [customQueryView removeTableColumn:[theColumns objectAtIndex:0]];
+ [customQueryView removeTableColumn:NSArrayObjectAtIndex(theColumns, 0)];
}
+ long queryCount = [queries count];
+
// Perform the supplied queries in series
- for ( i = 0 ; i < [queries count] ; i++ ) {
+ for ( i = 0 ; i < queryCount ; i++ ) {
// Don't run blank queries, or queries which only contain whitespace.
- if ([[[queries objectAtIndex:i] stringByTrimmingCharactersInSet:whitespaceAndNewlineSet] length] == 0)
+ if ([[NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewlineSet] length] == 0)
continue;
// Run the query, timing execution (note this also includes network and overhead)
@@ -433,7 +436,7 @@
if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
// If the query errored, append error to the error log for display at the end
- if ( [queries count] > 1 ) {
+ if ( queryCount > 1 ) {
if(firstErrorOccuredInQuery == -1)
firstErrorOccuredInQuery = i+1;
@@ -705,7 +708,7 @@
// the extra semicolon at the end of each query
for (i = 0; i < queryCount; i++ ) {
- queryRange = [[queries objectAtIndex:i] rangeValue];
+ queryRange = [NSArrayObjectAtIndex(queries, i) rangeValue];
queryPosition = NSMaxRange(queryRange);
queryStartPosition = queryRange.location;
@@ -722,7 +725,7 @@
if (position == queryStartPosition) positionAssociatedWithPreviousQuery = YES;
// If the caret is in between a user-defined delimiter whose length is >1, always associate
- if (!positionAssociatedWithPreviousQuery && i && NSMaxRange([[queries objectAtIndex:i-1] rangeValue]) < position && position < queryStartPosition) positionAssociatedWithPreviousQuery = YES;
+ if (!positionAssociatedWithPreviousQuery && i && NSMaxRange([NSArrayObjectAtIndex(queries, i-1) rangeValue]) < position && position < queryStartPosition) positionAssociatedWithPreviousQuery = YES;
// Otherwise associate if only whitespace since previous, and a newline before next.
if (!positionAssociatedWithPreviousQuery) {
@@ -742,7 +745,7 @@
}
// If there is a previous query and the position should be associated with it, do so.
- if (i && positionAssociatedWithPreviousQuery && [[[[textView string] substringWithRange:[[queries objectAtIndex:i-1] rangeValue]] stringByTrimmingCharactersInSet:whitespaceAndNewlineSet] length]) {
+ if (i && positionAssociatedWithPreviousQuery && [[[[textView string] substringWithRange:[NSArrayObjectAtIndex(queries, i-1) rangeValue]] stringByTrimmingCharactersInSet:whitespaceAndNewlineSet] length]) {
queryRange = [[queries objectAtIndex:i-1] rangeValue];
break;
}
@@ -1053,8 +1056,8 @@
NSRunAlertPanel(@"Query already exists", @"The query you are adding to your favorites already exists.", @"OK", nil, nil);
//remove row if it was a (blank) new row or a copied row
- if ( [[queryFavorites objectAtIndex:rowIndex] isEqualToString:@""] ||
- [[queryFavorites objectAtIndex:rowIndex] isEqualToString:anObject] ) {
+ if ( [NSArrayObjectAtIndex(queryFavorites, rowIndex) isEqualToString:@""] ||
+ [NSArrayObjectAtIndex(queryFavorites, rowIndex) isEqualToString:anObject] ) {
[queryFavoritesView deselectAll:self];
[queryFavorites removeObjectAtIndex:rowIndex];
[queryFavoritesView reloadData];
diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m
index 2cd2508a..1743782b 100644
--- a/Source/NoodleLineNumberView.m
+++ b/Source/NoodleLineNumberView.m
@@ -31,6 +31,7 @@
// functionality and adds selection by clicking on the ruler.
#import "NoodleLineNumberView.h"
+#import "SPArrayAdditions.h"
#define DEFAULT_THICKNESS 22.0
#define RULER_MARGIN 5.0
@@ -207,7 +208,7 @@
for (line = 0; line < count; line++)
{
- index = [[lines objectAtIndex:line] unsignedIntValue];
+ index = [NSArrayObjectAtIndex(lines, line) unsignedIntValue];
rects = [layoutManager rectArrayForCharacterRange:NSMakeRange(index, 0)
withinSelectedCharacterRange:nullRange
@@ -299,7 +300,7 @@
while ((right - left) > 1)
{
mid = (right + left) / 2;
- lineStart = [[lines objectAtIndex:mid] unsignedIntValue];
+ lineStart = [NSArrayObjectAtIndex(lines, mid) unsignedIntValue];
if (index < lineStart)
{
@@ -405,7 +406,7 @@
for (line = [self lineNumberForCharacterIndex:range.location inText:text]; line < count; line++)
{
- index = [[lines objectAtIndex:line] unsignedIntValue];
+ index = [NSArrayObjectAtIndex(lines, line) unsignedIntValue];
if (NSLocationInRange(index, range))
{
diff --git a/Source/SPArrayAdditions.h b/Source/SPArrayAdditions.h
index 7a672dc0..044699db 100644
--- a/Source/SPArrayAdditions.h
+++ b/Source/SPArrayAdditions.h
@@ -24,6 +24,15 @@
#import <Cocoa/Cocoa.h>
+static inline id NSArrayObjectAtIndex(NSArray* self, NSUInteger i) {
+ typedef id (*SPArrayObjectAtIndexMethodPtr)(NSArray*, SEL, NSUInteger);
+ static SPArrayObjectAtIndexMethodPtr SPNSArrayObjectAtIndex;
+ if (!SPNSArrayObjectAtIndex) SPNSArrayObjectAtIndex = (SPArrayObjectAtIndexMethodPtr)[self methodForSelector:@selector(objectAtIndex:)];
+ id to_return = SPNSArrayObjectAtIndex(self, @selector(objectAtIndex:), i);
+ return to_return;
+}
+
+
@interface NSArray (SPArrayAdditions)
- (NSString *)componentsJoinedAndBacktickQuoted;
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index bd72c9d2..b76ea41f 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -24,6 +24,7 @@
#import "SPExportController.h"
#import "TablesList.h"
+#import "SPArrayAdditions.h"
@implementation SPExportController
@@ -78,7 +79,7 @@
for ( i = 0 ; i < [queryResult numOfRows] ; i++ ) {
[tables addObject:[NSMutableArray arrayWithObjects:
[NSNumber numberWithBool:YES],
- [[queryResult fetchRowAsArray] objectAtIndex:0],
+ NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0),
nil
]];
}
@@ -118,9 +119,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
id returnObject = nil;
if ( [[aTableColumn identifier] isEqualToString:@"switch"] ) {
- returnObject = [[tables objectAtIndex:rowIndex] objectAtIndex:0];
+ returnObject = NSArrayObjectAtIndex([tables objectAtIndex:rowIndex], 0);
} else {
- returnObject = [[tables objectAtIndex:rowIndex] objectAtIndex:1];
+ returnObject = NSArrayObjectAtIndex([tables objectAtIndex:rowIndex], 1);
}
return returnObject;
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index e5dc43ea..591b40d0 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -27,6 +27,7 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPNarrowDownCompletion.h"
+#import "SPArrayAdditions.h"
#import "ImageAndTextCell.h"
#import <Foundation/NSObjCRuntime.h>
@@ -268,9 +269,9 @@
for(i=0; i<[newFiltered count]; i++)
{
if(dictMode)
- item = [newFiltered objectAtIndex:i];
+ item = NSArrayObjectAtIndex([newFiltered objectAtIndex:i], 0);
else
- item = [[newFiltered objectAtIndex:i] objectForKey:@"display"];
+ item = [NSArrayObjectAtIndex([newFiltered objectAtIndex:i], 0) objectForKey:@"display"];
// If space in suggestion add space to allowed input chars
if(!spaceInSuggestion && [item rangeOfString:@" "].length) {
[textualInputCharacters addCharactersInString:@" "];
diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m
index dab9a9a0..d7f29811 100644
--- a/Source/SPQueryConsole.m
+++ b/Source/SPQueryConsole.m
@@ -25,6 +25,7 @@
#import "SPQueryConsole.h"
#import "SPConsoleMessage.h"
+#import "SPArrayAdditions.h"
#define MESSAGE_TRUNCATE_CHARACTER_LENGTH 256
#define MESSAGE_TIME_STAMP_FORMAT @"%H:%M:%S"
@@ -147,7 +148,7 @@ static SPQueryConsole *sharedQueryConsole = nil;
while (i != NSNotFound)
{
if (i < [messagesVisibleSet count]) {
- SPConsoleMessage *message = [messagesVisibleSet objectAtIndex:i];
+ SPConsoleMessage *message = NSArrayObjectAtIndex(messagesVisibleSet, i);
NSString *consoleMessage = [message message];
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index f2e0c77e..8fd2f26c 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -31,6 +31,7 @@
#import "TableDocument.h"
#import "TablesList.h"
#import "SPStringAdditions.h"
+#import "SPArrayAdditions.h"
@implementation SPTableData
@@ -339,10 +340,13 @@
tableColumn = [[NSMutableDictionary alloc] init];
definitionParts = [[NSMutableArray alloc] init];
fieldParser = [[SPSQLParser alloc] init];
+
+ NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+
for (i = 0; i < [fieldStrings count]; i++) {
// Take this field/key string, trim whitespace from both ends and remove comments
- [fieldsParser setString:[[fieldStrings objectAtIndex:i] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
+ [fieldsParser setString:[NSArrayObjectAtIndex(fieldStrings, i) stringByTrimmingCharactersInSet:whitespaceAndNewlineSet]];
[fieldsParser deleteComments];
if (![fieldsParser length]) {
continue;
@@ -411,60 +415,60 @@
// NOTE: this won't get SET NULL | NO ACTION
if( [[parts objectAtIndex:9] hasPrefix:@"UPDATE"] ) {
//NSLog( @"update: %@", [parts objectAtIndex:10] );
- if( [[parts objectAtIndex:10] hasPrefix:@"SET"] ) {
+ if( [NSArrayObjectAtIndex(parts, 10) hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"update"];
nextOffs = 13;
- } else if( [[parts objectAtIndex:10] hasPrefix:@"NO"] ) {
+ } else if( [NSArrayObjectAtIndex(parts, 10) hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"update"];
nextOffs = 13;
} else {
- [constraintDetails setObject:[parts objectAtIndex:10]
- forKey:@"update"];
+ [constraintDetails setObject:NSArrayObjectAtIndex(parts, 10)
+ forKey:@"update"];
}
}
- else if( [[parts objectAtIndex:9] hasPrefix:@"DELETE"] ) {
- //NSLog( @"delete: %@", [parts objectAtIndex:10] );
- if( [[parts objectAtIndex:10] hasPrefix:@"SET"] ) {
+ else if( [NSArrayObjectAtIndex(parts, 9) hasPrefix:@"DELETE"] ) {
+ //NSLog( @"delete: %@", [parts objectAtIndex:10] );
+ if( [NSArrayObjectAtIndex(parts, 10) hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"delete"];
nextOffs = 13;
- } else if( [[parts objectAtIndex:10] hasPrefix:@"NO"] ) {
+ } else if( [NSArrayObjectAtIndex(parts, 10) hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"delete"];
nextOffs = 13;
} else {
- [constraintDetails setObject:[parts objectAtIndex:10]
- forKey:@"delete"];
+ [constraintDetails setObject:NSArrayObjectAtIndex(parts, 10)
+ forKey:@"delete"];
}
}
}
if( [parts count] > nextOffs - 1 ) {
- if( [[parts objectAtIndex:nextOffs] hasPrefix:@"UPDATE"] ) {
+ if( [NSArrayObjectAtIndex(parts, nextOffs) hasPrefix:@"UPDATE"] ) {
//NSLog( @"update: %@", [parts objectAtIndex:13] );
- if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"SET"] ) {
+ if( [NSArrayObjectAtIndex(parts, nextOffs+1) hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"update"];
- } else if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"NO"] ) {
+ } else if( [NSArrayObjectAtIndex(parts, nextOffs+1) hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"update"];
} else {
- [constraintDetails setObject:[parts objectAtIndex:nextOffs+1]
- forKey:@"update"];
+ [constraintDetails setObject:NSArrayObjectAtIndex(parts, nextOffs+1)
+ forKey:@"update"];
}
}
- else if( [[parts objectAtIndex:nextOffs] hasPrefix:@"DELETE"] ) {
- //NSLog( @"delete: %@", [parts objectAtIndex:13] );
- if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"SET"] ) {
+ else if( [NSArrayObjectAtIndex(parts, nextOffs) hasPrefix:@"DELETE"] ) {
+ //NSLog( @"delete: %@", [parts objectAtIndex:13] );
+ if( [NSArrayObjectAtIndex(parts, nextOffs+1) hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"delete"];
- } else if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"NO"] ) {
+ } else if( [NSArrayObjectAtIndex(parts, nextOffs+1) hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"delete"];
} else {
- [constraintDetails setObject:[parts objectAtIndex:nextOffs+1]
- forKey:@"delete"];
+ [constraintDetails setObject:NSArrayObjectAtIndex(parts, nextOffs+1)
+ forKey:@"delete"];
}
}
}
@@ -472,11 +476,11 @@
[constraintDetails release];
}
// primary key
- else if( [[parts objectAtIndex:0] hasPrefix:@"PRIMARY"] ) {
- //NSLog( @"pkey is %@", [[parts objectAtIndex:2] stringByTrimmingCharactersInSet:junk] );
+ else if( [NSArrayObjectAtIndex(parts, 0) hasPrefix:@"PRIMARY"] ) {
+ //NSLog( @"pkey is %@", [[parts objectAtIndex:2] stringByTrimmingCharactersInSet:junk] );
}
// key
- else if( [[parts objectAtIndex:0] hasPrefix:@"KEY"] ) {
+ else if( [NSArrayObjectAtIndex(parts, 0) hasPrefix:@"KEY"] ) {
/*
NSLog( @"key %@.%@",
[[parts objectAtIndex:1] stringByTrimmingCharactersInSet:junk],
diff --git a/Source/TableContent.m b/Source/TableContent.m
index bbda4d44..4d68ce1f 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -109,7 +109,7 @@
theColumns = [tableContentView tableColumns];
while ([theColumns count]) {
- [tableContentView removeTableColumn:[theColumns objectAtIndex:0]];
+ [tableContentView removeTableColumn:NSArrayObjectAtIndex(theColumns, 0)];
}
// If no table has been supplied, reset the view to a blank table and disabled elements.
@@ -167,7 +167,7 @@
// Add the new columns to the table
for ( i = 0 ; i < [theColumns count] ; i++ ) {
- columnDefinition = [theColumns objectAtIndex:i];
+ columnDefinition = NSArrayObjectAtIndex(theColumns, i);
// Set up the column
theCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"name"]];
@@ -718,7 +718,7 @@
columns = [[NSArray alloc] initWithArray:[tableDataInstance columns]];
for ( i = 0 ; i < [columns count] ; i++ ) {
- column = [columns objectAtIndex:i];
+ column = NSArrayObjectAtIndex(columns, i);
if ([column objectForKey:@"default"] == nil || [[column objectForKey:@"default"] isEqualToString:@"NULL"]) {
[newRow setObject:[prefs stringForKey:@"NullValue"] forKey:[column objectForKey:@"name"]];
} else {
@@ -1438,8 +1438,8 @@
// Add values for hidden blob and text fields if appropriate
if ( [prefs boolForKey:@"LoadBlobsAsNeeded"] ) {
for ( j = 0 ; j < [columns count] ; j++ ) {
- if ( [tableDataInstance columnIsBlobOrText:[[columns objectAtIndex:j] objectForKey:@"name"] ] ) {
- [modifiedRow setObject:NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields") forKey:[[columns objectAtIndex:j] objectForKey:@"name"]];
+ if ( [tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(columns, j) objectForKey:@"name"] ] ) {
+ [modifiedRow setObject:NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields") forKey:[NSArrayObjectAtIndex(columns, j) objectForKey:@"name"]];
}
}
}
@@ -1489,7 +1489,7 @@
NSMutableArray *fieldValues = [[NSMutableArray alloc] init];
// Get the field values
for ( i = 0 ; i < [columnNames count] ; i++ ) {
- rowObject = [[filteredResult objectAtIndex:currentlyEditingRow] objectForKey:[columnNames objectAtIndex:i]];
+ rowObject = [NSArrayObjectAtIndex(filteredResult, currentlyEditingRow) objectForKey:NSArrayObjectAtIndex(columnNames, i)];
// Convert the object to a string (here we can add special treatment for date-, number- and data-fields)
if ( [[rowObject description] isEqualToString:[prefs stringForKey:@"NullValue"]]
|| ([rowObject isMemberOfClass:[NSString class]] && [[rowObject description] isEqualToString:@""]) ) {
@@ -1510,7 +1510,7 @@
} else {
if ( [[rowObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) {
[rowValue setString:@"CURRENT_TIMESTAMP"];
- } else if ([[[theColumns objectAtIndex:i] objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+ } else if ([[NSArrayObjectAtIndex(theColumns, i) objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
[rowValue setString:((![[rowObject description] length] || [[rowObject description] isEqualToString:@"0"])?@"0":@"1")];
} else {
[rowValue setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:[rowObject description]]]];
@@ -1533,7 +1533,7 @@
[queryString appendString:@", "];
}
[queryString appendString:[NSString stringWithFormat:@"%@=%@",
- [[columnNames objectAtIndex:i] backtickQuotedString], [fieldValues objectAtIndex:i]]];
+ [NSArrayObjectAtIndex(columnNames, i) backtickQuotedString], [fieldValues objectAtIndex:i]]];
}
[queryString appendString:[NSString stringWithFormat:@" WHERE %@", [self argumentForRow:-2]]];
}
@@ -1570,9 +1570,9 @@
// Set the insertId for fields with auto_increment
for ( i = 0; i < [theColumns count] ; i++ ) {
- if ([[[theColumns objectAtIndex:i] objectForKey:@"autoincrement"] intValue]) {
+ if ([[NSArrayObjectAtIndex(theColumns, i) objectForKey:@"autoincrement"] intValue]) {
[[filteredResult objectAtIndex:currentlyEditingRow] setObject:[[NSNumber numberWithLong:[mySQLConnection insertId]] description]
- forKey:[columnNames objectAtIndex:i]];
+ forKey:NSArrayObjectAtIndex(columnNames, i)];
}
}
[fullResult addObject:[filteredResult objectAtIndex:currentlyEditingRow]];
@@ -1710,11 +1710,11 @@
// Use the selected row if appropriate
if ( row >= 0 ) {
- tempValue = [[filteredResult objectAtIndex:row] objectForKey:[keys objectAtIndex:i]];
+ tempValue = [NSArrayObjectAtIndex(filteredResult, row) objectForKey:NSArrayObjectAtIndex(keys, i)];
// Otherwise use the oldRow
} else {
- tempValue = [oldRow objectForKey:[keys objectAtIndex:i]];
+ tempValue = [oldRow objectForKey:NSArrayObjectAtIndex(keys, i)];
}
if ( [tempValue isKindOfClass:[NSData class]] ) {
@@ -1728,7 +1728,7 @@
}
if ( [value isEqualToString:[prefs stringForKey:@"NullValue"]] ) {
- [argument appendString:[NSString stringWithFormat:@"%@ IS NULL", [[keys objectAtIndex:i] backtickQuotedString]]];
+ [argument appendString:[NSString stringWithFormat:@"%@ IS NULL", [NSArrayObjectAtIndex(keys, i) backtickQuotedString]]];
} else {
// Escape special characters (in WHERE statement!)
@@ -1750,9 +1750,9 @@
columnType = [[tableDataInstance columnWithName:[keys objectAtIndex:i]] objectForKey:@"typegrouping"];
if ( [columnType isEqualToString:@"integer"] || [columnType isEqualToString:@"float"] || [columnType isEqualToString:@"bit"] ) {
- [argument appendString:[NSString stringWithFormat:@"%@ = %@", [[keys objectAtIndex:i] backtickQuotedString], value]];
+ [argument appendString:[NSString stringWithFormat:@"%@ = %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
} else {
- [argument appendString:[NSString stringWithFormat:@"%@ LIKE %@", [[keys objectAtIndex:i] backtickQuotedString], value]];
+ [argument appendString:[NSString stringWithFormat:@"%@ LIKE %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
}
}
}
@@ -1772,7 +1772,7 @@
NSArray *tableColumns = [tableDataInstance columns];
for ( i = 0 ; i < [tableColumns count]; i++ ) {
- if ( [tableDataInstance columnIsBlobOrText:[[tableColumns objectAtIndex:i] objectForKey:@"name"]] ) {
+ if ( [tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(tableColumns, i) objectForKey:@"name"]] ) {
return YES;
}
}
@@ -1793,14 +1793,14 @@
if ( [prefs boolForKey:@"LoadBlobsAsNeeded"] ) {
for ( i = 0 ; i < [columnNames count] ; i++ ) {
- if (![tableDataInstance columnIsBlobOrText:[[columns objectAtIndex:i] objectForKey:@"name"]] ) {
- [fields addObject:[columnNames objectAtIndex:i]];
+ if (![tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(columns, i) objectForKey:@"name"]] ) {
+ [fields addObject:NSArrayObjectAtIndex(columnNames, i)];
}
}
// Always select at least one field - the first if there are no non-blob fields.
if ( [fields count] == 0 ) {
- return [[columnNames objectAtIndex:0] backtickQuotedString];
+ return [NSArrayObjectAtIndex(columnNames, 0) backtickQuotedString];
} else {
return [fields componentsJoinedAndBacktickQuoted];
}
@@ -1893,7 +1893,7 @@
} else {
for ( i = 0 ; i < [filteredResult count] ; i++ ) {
if ( ![tempArray containsObject:[NSNumber numberWithInt:i]] )
- [tempResult addObject:[filteredResult objectAtIndex:i]];
+ [tempResult addObject:NSArrayObjectAtIndex(filteredResult, i)];
}
[filteredResult setArray:tempResult];
numRows = [self getNumberOfRows];
@@ -2431,7 +2431,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
// Check if next column is a blob column, and skip to the next non-blob column
i = 1;
while (
- (fieldType = [[tableDataInstance columnWithName:[[[tableContentView tableColumns] objectAtIndex:column+i] identifier]] objectForKey:@"typegrouping"])
+ (fieldType = [[tableDataInstance columnWithName:[NSArrayObjectAtIndex([tableContentView tableColumns], column+i) identifier]] objectForKey:@"typegrouping"])
&& ([fieldType isEqualToString:@"textdata"] || [fieldType isEqualToString:@"blobdata"])
) {
i++;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 270ebe5b..f98a2c1c 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -40,6 +40,7 @@
#import "SPTableData.h"
#import "SPDatabaseData.h"
#import "SPStringAdditions.h"
+#import "SPArrayAdditions.h"
#import "SPQueryConsole.h"
#import "CMMCPConnection.h"
#import "CMMCPResult.h"
@@ -794,7 +795,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
for (i = 0 ; i < [queryResult numOfRows] ; i++)
{
- [chooseDatabaseButton addItemWithTitle:[[queryResult fetchRowAsArray] objectAtIndex:0]];
+ [chooseDatabaseButton addItemWithTitle:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0)];
}
(![self database]) ? [chooseDatabaseButton selectItemAtIndex:0] : [chooseDatabaseButton selectItemWithTitle:[self database]];
@@ -951,7 +952,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
int r = [theResult numOfRows];
if (r) [theResult dataSeek:0];
for ( i = 0 ; i < r ; i++ ) {
- dbName = [[theResult fetchRowAsArray] objectAtIndex:0];
+ dbName = NSArrayObjectAtIndex([theResult fetchRowAsArray], 0);
}
if(![dbName isKindOfClass:[NSNull class]]) {
if(![dbName isEqualToString:selectedDatabase]) {
diff --git a/Source/TableDump.m b/Source/TableDump.m
index a309c22a..1490299a 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -53,7 +53,7 @@
if ([queryResult numOfRows]) [queryResult dataSeek:0];
for ( i = 0 ; i < [queryResult numOfRows] ; i++ ) {
[tables addObject:[NSMutableArray arrayWithObjects:
- [NSNumber numberWithBool:YES], [[queryResult fetchRowAsArray] objectAtIndex:0], nil]];
+ [NSNumber numberWithBool:YES], NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0), nil]];
}
[exportDumpTableView reloadData];
@@ -481,10 +481,9 @@
if (importSQLAsUTF8)
for ( i = 0 ; i < queryCount ; i++ ) {
[singleProgressBar setDoubleValue:(i*100/queryCount)];
- // [singleProgressBar displayIfNeeded];
// Skip blank or whitespace-only queries to avoid errors
- NSString *q = [[queries objectAtIndex:i] stringByTrimmingCharactersInSet:whitespaceAndNewline];
+ NSString *q = [NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewline];
if (![q length]) continue;
[mySQLConnection queryString:q usingEncoding:NSUTF8StringEncoding];
@@ -496,10 +495,9 @@
else
for ( i = 0 ; i < queryCount ; i++ ) {
[singleProgressBar setDoubleValue:(i*100/queryCount)];
- // [singleProgressBar displayIfNeeded];
// Skip blank or whitespace-only queries to avoid errors
- NSString *q = [[queries objectAtIndex:i] stringByTrimmingCharactersInSet:whitespaceAndNewline];
+ NSString *q = [NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewline];
if (![q length]) continue;
[mySQLConnection queryString:q];
@@ -591,7 +589,7 @@
theResult = (CMMCPResult *) [mySQLConnection listTables];
if ([theResult numOfRows]) [theResult dataSeek:0];
for ( i = 0 ; i < [theResult numOfRows] ; i++ ) {
- [fieldMappingPopup addItemWithTitle:[[theResult fetchRowAsArray] objectAtIndex:0]];
+ [fieldMappingPopup addItemWithTitle:NSArrayObjectAtIndex([theResult fetchRowAsArray], 0)];
}
if ([tableDocumentInstance table] != nil && ![(NSString *)[tableDocumentInstance table] isEqualToString:@""]) {
@@ -655,19 +653,20 @@
// get fields to be imported
for (i = 0; i < [fieldMappingArray count] ; i++ ) {
- if ([[fieldMappingArray objectAtIndex:i] intValue] > 0) {
+ if ([NSArrayObjectAtIndex(fieldMappingArray, i) intValue] > 0) {
if ( [fNames length] )
[fNames appendString:@","];
- [fNames appendString:[[[tableSourceInstance fieldNames] objectAtIndex:i] backtickQuotedString]];
+ [fNames appendString:[NSArrayObjectAtIndex([tableSourceInstance fieldNames], i) backtickQuotedString]];
}
}
//import array
- for ( i = 0 ; i < [importArray count] ; i++ ) {
+ long importArrayCount = [importArray count];
+ for ( i = 0 ; i < importArrayCount ; i++ ) {
//show progress bar
- [singleProgressBar setDoubleValue:((i+1)*100/[importArray count])];
- [singleProgressBar displayIfNeeded];
+ [singleProgressBar setDoubleValue:((i+1)*100/importArrayCount)];
+ // [singleProgressBar displayIfNeeded];
if ( !([importFieldNamesSwitch state] && (i == 0)) ) {
//put values in string
@@ -675,14 +674,14 @@
for ( j = 0 ; j < [fieldMappingArray count] ; j++ ) {
- if ([[fieldMappingArray objectAtIndex:j] intValue] > 0) {
+ if ([NSArrayObjectAtIndex(fieldMappingArray,j) intValue] > 0) {
if ( [fValues length] )
[fValues appendString:@","];
- if ([[[importArray objectAtIndex:i] objectAtIndex:([[fieldMappingArray objectAtIndex:j] intValue] - 1)] isMemberOfClass:[NSNull class]] ) {
+ if ([[NSArrayObjectAtIndex(importArray, i) objectAtIndex:([NSArrayObjectAtIndex(fieldMappingArray, j) intValue] - 1)] isMemberOfClass:[NSNull class]] ) {
[fValues appendString:@"NULL"];
} else {
- [fValues appendString:[NSString stringWithFormat:@"'%@'",[mySQLConnection prepareString:[[importArray objectAtIndex:i] objectAtIndex:([[fieldMappingArray objectAtIndex:j] intValue] - 1)]]]];
+ [fValues appendString:[NSString stringWithFormat:@"'%@'",[mySQLConnection prepareString:[NSArrayObjectAtIndex(importArray ,i) objectAtIndex:([NSArrayObjectAtIndex(fieldMappingArray ,j) intValue] - 1)]]]];
}
}
}
@@ -694,7 +693,7 @@
fValues]];
if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in line %d] %@\n", @"error text when reading of csv file gave errors"), (i+1),[mySQLConnection getLastErrorMessage]]];
+ [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in line %d] %@\n", @"error text when reading of csv file gave errors"), (i+1),[mySQLConnection getLastErrorMessage]]];
}
}
}
@@ -759,8 +758,8 @@
if (!fieldMappingArray) {
fieldMappingArray = [NSMutableArray array];
- for (i = 0; i < [[tableSourceInstance fieldNames] count]; i++) {
- if (i < [[importArray objectAtIndex:currentRow] count] && ![[[importArray objectAtIndex:currentRow] objectAtIndex:i] isKindOfClass:[NSNull class]]) {
+ for (i = 0; i < [[tableSourceInstance fieldNames] count]; i++) {
+ if (i < [NSArrayObjectAtIndex(importArray, currentRow) count] && ![NSArrayObjectAtIndex(NSArrayObjectAtIndex(importArray, currentRow), i) isKindOfClass:[NSNull class]]) {
value = i + 1;
} else {
value = 0;
@@ -785,7 +784,7 @@
if ([[fieldMappingButtonOptions objectAtIndex:i] isNSNull]) {
[fieldMappingButtonOptions replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%i. %@", i+1, [prefs objectForKey:@"NullValue"]]];
} else {
- [fieldMappingButtonOptions replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%i. %@", i+1, [fieldMappingButtonOptions objectAtIndex:i]]];
+ [fieldMappingButtonOptions replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%i. %@", i+1, NSArrayObjectAtIndex(fieldMappingButtonOptions, i)]];
}
}
}
@@ -855,8 +854,8 @@
// Copy over the selected table names into a table in preparation for iteration
for ( i = 0 ; i < [tables count] ; i++ ) {
- if ( [[[tables objectAtIndex:i] objectAtIndex:0] boolValue] ) {
- [selectedTables addObject:[NSString stringWithString:[[tables objectAtIndex:i] objectAtIndex:1]]];
+ if ( [NSArrayObjectAtIndex(NSArrayObjectAtIndex(tables, i), 0) boolValue] ) {
+ [selectedTables addObject:[NSString stringWithString:NSArrayObjectAtIndex(NSArrayObjectAtIndex(tables, i), 1)]];
}
}
@@ -899,7 +898,7 @@
lastProgressValue = 0;
// Update the progress text and reset the progress bar to indeterminate status while fetching data
- tableName = [selectedTables objectAtIndex:i];
+ tableName = NSArrayObjectAtIndex(selectedTables, i);
[singleProgressText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Table %i of %i (%@): Fetching data...", @"text showing that app is fetching data for table dump"), (i+1), [selectedTables count], tableName]];
[singleProgressText displayIfNeeded];
[singleProgressBar setIndeterminate:YES];
@@ -958,7 +957,7 @@
colCount = [[tableDetails objectForKey:@"columns"] count];
tableColumnNumericStatus = [NSMutableArray arrayWithCapacity:colCount];
for ( j = 0; j < colCount ; j++ ) {
- tableColumnTypeGrouping = [[[tableDetails objectForKey:@"columns"] objectAtIndex:j] objectForKey:@"typegrouping"];
+ tableColumnTypeGrouping = [NSArrayObjectAtIndex([tableDetails objectForKey:@"columns"], j) objectForKey:@"typegrouping"];
if ([tableColumnTypeGrouping isEqualToString:@"bit"] || [tableColumnTypeGrouping isEqualToString:@"integer"]
|| [tableColumnTypeGrouping isEqualToString:@"float"]) {
[tableColumnNumericStatus addObject:[NSNumber numberWithBool:YES]];
@@ -1212,19 +1211,19 @@
cinfo = [tinfo objectForKey:@"constraints"];
for( int j = 0; j < [cinfo count]; j++ ) {
// get the column refs. these can be comma separated.
- NSString *ccol = [[cinfo objectAtIndex:j] objectForKey:@"columns"];
- NSString *rcol = [[cinfo objectAtIndex:j] objectForKey:@"ref_columns"];
+ NSString *ccol = [NSArrayObjectAtIndex(cinfo, j) objectForKey:@"columns"];
+ NSString *rcol = [NSArrayObjectAtIndex(cinfo, j) objectForKey:@"ref_columns"];
NSString *extra = @"";
NSArray *tc = [ccol componentsSeparatedByString:@","];
if( [tc count] > 1 ) {
extra = @" [ arrowhead=crow, arrowtail=odiamond ]";
- ccol = [tc objectAtIndex:0];
- rcol = [[ccol componentsSeparatedByString:@","] objectAtIndex:0];
+ ccol = NSArrayObjectAtIndex(tc, 0);
+ rcol = NSArrayObjectAtIndex([ccol componentsSeparatedByString:@","], 0);
}
[fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@",
tableName,
ccol,
- [[cinfo objectAtIndex:j] objectForKey:@"ref_table"],
+ [NSArrayObjectAtIndex(cinfo, j) objectForKey:@"ref_table"],
rcol,
extra
]];
@@ -1328,7 +1327,7 @@
// Set the progress text
[singleProgressText setStringValue:NSLocalizedString(@"Exporting...", @"text showing that app is exporting to text file")];
- [singleProgressText displayIfNeeded];
+ // [singleProgressText displayIfNeeded];
// Open progress sheet
@@ -1372,7 +1371,7 @@
[csvRow setArray:[queryResult fetchRowAsArray]];
}
} else {
- [csvRow setArray:[array objectAtIndex:i]];
+ [csvRow setArray:NSArrayObjectAtIndex(array, i)];
}
[csvString setString:@""];
@@ -1386,14 +1385,14 @@
}
// Retrieve the contents of this cell
- if ([[csvRow objectAtIndex:j] isKindOfClass:[NSData class]]) {
- dataConversionString = [[NSString alloc] initWithData:[csvRow objectAtIndex:j] encoding:tableEncoding];
+ if ([NSArrayObjectAtIndex(csvRow, j) isKindOfClass:[NSData class]]) {
+ dataConversionString = [[NSString alloc] initWithData:NSArrayObjectAtIndex(csvRow, j) encoding:tableEncoding];
if (dataConversionString == nil)
- dataConversionString = [[NSString alloc] initWithData:[csvRow objectAtIndex:j] encoding:NSASCIIStringEncoding];
+ dataConversionString = [[NSString alloc] initWithData:NSArrayObjectAtIndex(csvRow, j) encoding:NSASCIIStringEncoding];
[csvCell setString:[NSString stringWithString:dataConversionString]];
[dataConversionString release];
} else {
- [csvCell setString:[[csvRow objectAtIndex:j] description]];
+ [csvCell setString:[NSArrayObjectAtIndex(csvRow, j) description]];
}
// For NULL values supplied via an array add the unenclosed null string as set in preferences
@@ -1408,12 +1407,12 @@
} else {
// Test whether this cell contains a number
- if ([[csvRow objectAtIndex:j] isKindOfClass:[NSData class]]) {
+ if ([NSArrayObjectAtIndex(csvRow, j) isKindOfClass:[NSData class]]) {
csvCellIsNumeric = FALSE;
// If an array of bools supplying information as to whether the column is numeric has been supplied, use it.
} else if (tableColumnNumericStatus != nil) {
- csvCellIsNumeric = [[tableColumnNumericStatus objectAtIndex:j] boolValue];
+ csvCellIsNumeric = [NSArrayObjectAtIndex(tableColumnNumericStatus, j) boolValue];
// Or fall back to testing numeric content via an NSScanner.
} else {
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 1cd8d8de..fd794cfc 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -33,6 +33,7 @@
#import "CMMCPConnection.h"
#import "CMMCPResult.h"
#import "SPStringAdditions.h"
+#import "SPArrayAdditions.h"
#import "RegexKitLite.h"
@implementation TablesList
@@ -105,21 +106,21 @@
if( [theResult numOfFields] == 1 ) {
for( i = 0; i < [theResult numOfRows]; i++ ) {
- [tables addObject:[[theResult fetchRowAsArray] objectAtIndex:3]];
- if( [[[theResult fetchRowAsArray] objectAtIndex:4] isEqualToString:@"PROCEDURE"]) {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
+ [tables addObject:NSArrayObjectAtIndex([theResult fetchRowAsArray],3)];
+ if( [NSArrayObjectAtIndex([theResult fetchRowAsArray], 4) isEqualToString:@"PROCEDURE"]) {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
} else {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
}
}
} else {
for( i = 0; i < [theResult numOfRows]; i++ ) {
resultRow = [theResult fetchRowAsArray];
- [tables addObject:[resultRow objectAtIndex:3]];
- if( [[resultRow objectAtIndex:4] isEqualToString:@"PROCEDURE"] ) {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
+ [tables addObject:NSArrayObjectAtIndex(resultRow, 3)];
+ if( [NSArrayObjectAtIndex(resultRow, 4) isEqualToString:@"PROCEDURE"] ) {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
} else {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
}
}
}