-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
7,200 additions
and
6,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Frameworks/SPMySQLFramework/Source/SPMySQLArrayAdditions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// SPMySQLArrayAdditions.h | ||
// Sequel Ace | ||
// | ||
// Created by James on 21/1/2021. | ||
// Copyright © 2021 Sequel-Ace. All rights reserved. | ||
// | ||
|
||
|
||
@interface NSArray (SPMySQLArrayAdditions) | ||
|
||
/** | ||
* Variant of objectAtIndex: that avoids the "index out of bounds" exception by | ||
* just returning nil instead. | ||
* | ||
* @warning This method is NOT thread-safe. | ||
* @param idx An index | ||
* @return The object located at index or nil. | ||
*/ | ||
- (nullable id)SPsafeObjectAtIndex:(NSUInteger)idx; | ||
@end | ||
|
||
@interface NSMutableArray (SPMutableArrayAdditions) | ||
|
||
- (void)SPsafeAddObject:(nullable id)obj; | ||
|
||
@end |
28 changes: 28 additions & 0 deletions
28
Frameworks/SPMySQLFramework/Source/SPMySQLArrayAdditions.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// SPMySQLArrayAdditions.m | ||
// Sequel Ace | ||
// | ||
// Created by James on 21/1/2021. | ||
// Copyright © 2021 Sequel-Ace. All rights reserved. | ||
// | ||
|
||
#import "SPMySQLArrayAdditions.h" | ||
|
||
@implementation NSArray (SPMySQLArrayAdditions) | ||
|
||
- (nullable id)SPsafeObjectAtIndex:(NSUInteger)idx | ||
{ | ||
return idx < self.count ? [self objectAtIndex:idx] : nil; | ||
} | ||
|
||
@end | ||
|
||
@implementation NSMutableArray (SPMySQLMutableArrayAdditions) | ||
|
||
- (void)SPsafeAddObject:(nullable id)obj{ | ||
if (obj != nil) { | ||
[self addObject:obj]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Frameworks/SPMySQLFramework/Source/SPMySQLMutableDictionaryAdditions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// SPMySQLMutableDictionaryAdditions.h | ||
// Sequel Ace | ||
// | ||
// Created by James on 21/1/2021. | ||
// Copyright © 2021 Sequel-Ace. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSMutableDictionary (SPMySQLMutableDictionaryAdditions) | ||
|
||
- (void)SPsafeSetObject:(id)obj forKey:(id)key; | ||
- (void)SPsafeRemoveObjectForKey:(nullable id)key; | ||
|
||
@end | ||
|
||
@interface NSDictionary (SPMySQLDictionaryAdditions) | ||
|
||
/*If obj or key are nil, does nothing. No exception thrown.*/ | ||
- (id)SPsafeObjectForKey:(id)key; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
44 changes: 44 additions & 0 deletions
44
Frameworks/SPMySQLFramework/Source/SPMySQLMutableDictionaryAdditions.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// SPMySQLMutableDictionaryAdditions.m | ||
// Sequel Ace | ||
// | ||
// Created by James on 21/1/2021. | ||
// Copyright © 2021 Sequel-Ace. All rights reserved. | ||
// | ||
|
||
#import "SPMySQLMutableDictionaryAdditions.h" | ||
|
||
@implementation NSMutableDictionary (SPMySQLMutableDictionaryAdditions) | ||
|
||
#pragma mark - | ||
#pragma mark NSMutableDictionary methods | ||
|
||
- (void)SPsafeSetObject:(id)obj forKey:(id)key { | ||
if (obj != nil & key != nil) { | ||
[self setObject:obj forKey:key]; | ||
} | ||
} | ||
|
||
- (void)SPsafeRemoveObjectForKey:(nullable id)key{ | ||
id object = [self SPsafeObjectForKey:key]; | ||
if (object != nil && object != [NSNull null]) { | ||
[self removeObjectForKey:key]; | ||
} | ||
} | ||
|
||
@end | ||
|
||
@implementation NSDictionary (SPMySQLDictionaryAdditions) | ||
|
||
#pragma mark - | ||
#pragma mark NSDictionary method | ||
|
||
- (id)SPsafeObjectForKey:(id)key { | ||
id object = [self objectForKey:key]; | ||
if (object != nil && object == [NSNull null]) { | ||
return nil; | ||
} | ||
return object; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.