Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Commit

Permalink
Perform a nullability audit
Browse files Browse the repository at this point in the history
  • Loading branch information
zwaldowski committed Jun 24, 2015
1 parent 1bad8ed commit e0d0e4b
Show file tree
Hide file tree
Showing 33 changed files with 182 additions and 50 deletions.
8 changes: 6 additions & 2 deletions BlocksKit/Core/NSArray+BlocksKit.h
Expand Up @@ -7,6 +7,8 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CGBase.h> // for CGFloat

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSArray.
Both inspired by and resembling Smalltalk syntax, these utilities
Expand Down Expand Up @@ -55,7 +57,7 @@
@return Returns the object, if found, or `nil`.
@see bk_select:
*/
- (id)bk_match:(BOOL (^)(id obj))block;
- (nullable id)bk_match:(BOOL (^)(id obj))block;

/** Loops through an array to find the objects matching the block.
Expand Down Expand Up @@ -117,7 +119,7 @@
@param block A block that takes the current sum and the next object to return the new sum.
@return An accumulated value.
*/
- (id)bk_reduce:(id)initial withBlock:(id (^)(id sum, id obj))block;
- (nullable id)bk_reduce:(nullable id)initial withBlock:(__nullable id (^)(__nullable id sum, id obj))block;

/**
Sometimes we just want to loop an objects list and reduce one property, where
Expand Down Expand Up @@ -219,3 +221,5 @@
- (BOOL)bk_corresponds:(NSArray *)list withBlock:(BOOL (^)(id obj1, id obj2))block;

@end

NS_ASSUME_NONNULL_END
6 changes: 5 additions & 1 deletion BlocksKit/Core/NSDictionary+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extension for NSDictionary.
Both inspired by and resembling Smalltalk syntax, this utility
Expand Down Expand Up @@ -49,7 +51,7 @@
@param block A BOOL-returning code block for a key/value pair.
@return The value of the first pair found;
*/
- (id)bk_match:(BOOL (^)(id key, id obj))block;
- (nullable id)bk_match:(BOOL (^)(id key, id obj))block;

/** Loops through a dictionary to find the key/value pairs matching the block.
Expand Down Expand Up @@ -109,3 +111,5 @@
- (BOOL)bk_all:(BOOL (^)(id key, id obj))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSIndexSet+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSIndexSet.
Both inspired by and resembling Smalltalk syntax, these utilities
Expand Down Expand Up @@ -118,3 +120,5 @@
- (BOOL)bk_none:(BOOL (^)(NSUInteger index))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSInvocation+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** BlocksKit extensions for NSInvocation. */
@interface NSInvocation (BlocksKit)

Expand All @@ -32,3 +34,5 @@
+ (NSInvocation *)bk_invocationWithTarget:(id)target block:(void (^)(id target))block;

@end

NS_ASSUME_NONNULL_END
6 changes: 5 additions & 1 deletion BlocksKit/Core/NSMapTable+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSMapTable (BlocksKit)

/** Loops through the maptable and executes the given block using each item.
Expand All @@ -22,7 +24,7 @@
@param block A BOOL-returning code block for a key/value pair.
@return The value of the first pair found;
*/
- (id)bk_match:(BOOL (^)(id key, id obj))block;
- (nullable id)bk_match:(BOOL (^)(id key, id obj))block;

/** Loops through a maptable to find the key/value pairs matching the block.
Expand Down Expand Up @@ -105,3 +107,5 @@
- (void)bk_performMap:(id (^)(id key, id obj))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSMutableArray+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSMutableArray.
These utilities expound upon the BlocksKit additions to the immutable
Expand Down Expand Up @@ -49,3 +51,5 @@
- (void)bk_performMap:(id (^)(id obj))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSMutableDictionary+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSMutableDictionary.
These utilities expound upon the BlocksKit additions to the immutable
Expand Down Expand Up @@ -45,3 +47,5 @@
- (void)bk_performMap:(id (^)(id key, id obj))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSMutableIndexSet+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSMutableIndexSet.
These utilities expound upon the BlocksKit additions to the immutable
Expand Down Expand Up @@ -41,3 +43,5 @@


@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSMutableOrderedSet+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSMutableOrderedSet.
These utilities expound upon the BlocksKit additions to the immutable
Expand Down Expand Up @@ -49,3 +51,5 @@
- (void)bk_performMap:(id (^)(id obj))block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSMutableSet+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSMutableSet.
These utilities expound upon the BlocksKit additions to the immutable
Expand Down Expand Up @@ -49,3 +51,5 @@
- (void)bk_performMap:(id (^)(id obj))block;

@end

NS_ASSUME_NONNULL_END
28 changes: 16 additions & 12 deletions BlocksKit/Core/NSObject+BKAssociatedObjects.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Objective-C wrapper for 10.6+ associated object API.
In Mac OS X Snow Leopard and iOS 3.0, Apple introduced an addition to the
Expand Down Expand Up @@ -37,15 +39,15 @@
@param value Any object.
@param key A unique key pointer.
*/
- (void)bk_associateValue:(id)value withKey:(const void *)key;
- (void)bk_associateValue:(nullable id)value withKey:(const void *)key;

/** Strongly associates an object with the receiving class.
@see associateValue:withKey:
@param value Any object.
@param key A unique key pointer.
*/
+ (void)bk_associateValue:(id)value withKey:(const void *)key;
+ (void)bk_associateValue:(nullable id)value withKey:(const void *)key;

/** Strongly, thread-safely associates an object with the reciever.
Expand All @@ -61,15 +63,15 @@
@param value Any object.
@param key A unique key pointer.
*/
- (void)bk_atomicallyAssociateValue:(id)value withKey:(const void *)key;
- (void)bk_atomicallyAssociateValue:(nullable id)value withKey:(const void *)key;

/** Strongly, thread-safely associates an object with the receiving class.
@see associateValue:withKey:
@param value Any object.
@param key A unique key pointer.
*/
+ (void)bk_atomicallyAssociateValue:(id)value withKey:(const void *)key;
+ (void)bk_atomicallyAssociateValue:(nullable id)value withKey:(const void *)key;

/** Associates a copy of an object with the reciever.
Expand All @@ -82,15 +84,15 @@
@param value Any object, pointer, or value.
@param key A unique key pointer.
*/
- (void)bk_associateCopyOfValue:(id)value withKey:(const void *)key;
- (void)bk_associateCopyOfValue:(nullable id)value withKey:(const void *)key;

/** Associates a copy of an object with the receiving class.
@see associateCopyOfValue:withKey:
@param value Any object, pointer, or value.
@param key A unique key pointer.
*/
+ (void)bk_associateCopyOfValue:(id)value withKey:(const void *)key;
+ (void)bk_associateCopyOfValue:(nullable id)value withKey:(const void *)key;

/** Thread-safely associates a copy of an object with the reciever.
Expand All @@ -104,15 +106,15 @@
@param value Any object, pointer, or value.
@param key A unique key pointer.
*/
- (void)bk_atomicallyAssociateCopyOfValue:(id)value withKey:(const void *)key;
- (void)bk_atomicallyAssociateCopyOfValue:(nullable id)value withKey:(const void *)key;

/** Thread-safely associates a copy of an object with the receiving class.
@see associateCopyOfValue:withKey:
@param value Any object, pointer, or value.
@param key A unique key pointer.
*/
+ (void)bk_atomicallyAssociateCopyOfValue:(id)value withKey:(const void *)key;
+ (void)bk_atomicallyAssociateCopyOfValue:(nullable id)value withKey:(const void *)key;

/** Weakly associates an object with the reciever.
Expand All @@ -123,30 +125,30 @@
@param value Any object.
@param key A unique key pointer.
*/
- (void)bk_weaklyAssociateValue:(__autoreleasing id)value withKey:(const void *)key;
- (void)bk_weaklyAssociateValue:(nullable __autoreleasing id)value withKey:(const void *)key;

/** Weakly associates an object with the receiving class.
@see weaklyAssociateValue:withKey:
@param value Any object.
@param key A unique key pointer.
*/
+ (void)bk_weaklyAssociateValue:(__autoreleasing id)value withKey:(const void *)key;
+ (void)bk_weaklyAssociateValue:(nullable __autoreleasing id)value withKey:(const void *)key;

/** Returns the associated value for a key on the reciever.
@param key A unique key pointer.
@return The object associated with the key, or `nil` if not found.
*/
- (id)bk_associatedValueForKey:(const void *)key;
- (nullable id)bk_associatedValueForKey:(const void *)key;

/** Returns the associated value for a key on the receiving class.
@see associatedValueForKey:
@param key A unique key pointer.
@return The object associated with the key, or `nil` if not found.
*/
+ (id)bk_associatedValueForKey:(const void *)key;
+ (nullable id)bk_associatedValueForKey:(const void *)key;

/** Returns the reciever to a clean state by removing all
associated objects, releasing them if necessary. */
Expand All @@ -157,3 +159,5 @@
+ (void)bk_removeAllAssociatedObjects;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSObject+BKBlockExecution.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block execution on *any* object.
This category overhauls the `performSelector:` utilities on
Expand Down Expand Up @@ -119,3 +121,5 @@
+ (void)bk_cancelBlock:(id <NSObject, NSCopying>)block;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions BlocksKit/Core/NSObject+BKBlockObservation.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Blocks wrapper for key-value observation.
In Mac OS X Panther, Apple introduced an API called "key-value
Expand Down Expand Up @@ -136,3 +138,5 @@
- (void)bk_removeAllBlockObservers;

@end

NS_ASSUME_NONNULL_END
8 changes: 6 additions & 2 deletions BlocksKit/Core/NSOrderedSet+BlocksKit.h
Expand Up @@ -6,6 +6,8 @@
#import "BKDefines.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** Block extensions for NSOrderedSet.
Both inspired by and resembling Smalltalk syntax, these utilities allow for
Expand Down Expand Up @@ -52,7 +54,7 @@
@return Returns the object, if found, or `nil`.
@see bk_select:
*/
- (id)bk_match:(BOOL (^)(id obj))block;
- (nullable id)bk_match:(BOOL (^)(id obj))block;

/** Loops through an ordered set to find the objects matching the block.
Expand Down Expand Up @@ -109,7 +111,7 @@
@param block A block that takes the current sum and the next object to return the new sum.
@return An accumulated value.
*/
- (id)bk_reduce:(id)initial withBlock:(id (^)(id sum, id obj))block;
- (nullable id)bk_reduce:(nullable id)initial withBlock:(__nullable id (^)(__nullable id sum, id obj))block;

/** Loops through an ordered set to find whether any object matches the block.
Expand Down Expand Up @@ -167,3 +169,5 @@
*/
- (BOOL)bk_corresponds:(NSOrderedSet *)list withBlock:(BOOL (^)(id obj1, id obj2))block;
@end

NS_ASSUME_NONNULL_END

0 comments on commit e0d0e4b

Please sign in to comment.