From 12f375a899aa8ae13bd8fdb8ce2e1e53980eadec Mon Sep 17 00:00:00 2001 From: featherless Date: Fri, 20 Sep 2019 00:23:33 -0400 Subject: [PATCH 1/2] [core] Add nullability annotations to NIActions. --- src/core/src/NIActions+Subclassing.h | 16 ++++++------ src/core/src/NIActions.h | 38 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/core/src/NIActions+Subclassing.h b/src/core/src/NIActions+Subclassing.h index ff397bce0..236d1c57f 100644 --- a/src/core/src/NIActions+Subclassing.h +++ b/src/core/src/NIActions+Subclassing.h @@ -18,20 +18,20 @@ @interface NIObjectActions : NSObject -@property (nonatomic, copy) NIActionBlock tapAction; -@property (nonatomic, copy) NIActionBlock detailAction; -@property (nonatomic, copy) NIActionBlock navigateAction; +@property (nonatomic, copy, nullable) NIActionBlock tapAction; +@property (nonatomic, copy, nullable) NIActionBlock detailAction; +@property (nonatomic, copy, nullable) NIActionBlock navigateAction; -@property (nonatomic) SEL tapSelector; -@property (nonatomic) SEL detailSelector; -@property (nonatomic) SEL navigateSelector; +@property (nonatomic, nullable) SEL tapSelector; +@property (nonatomic, nullable) SEL detailSelector; +@property (nonatomic, nullable) SEL navigateSelector; @end @interface NIActions () -@property (nonatomic, weak) id target; +@property (nonatomic, weak, nullable) id target; -- (NIObjectActions *)actionForObjectOrClassOfObject:(id)object; +- (nullable NIObjectActions *)actionForObjectOrClassOfObject:(nonnull id)object; @end diff --git a/src/core/src/NIActions.h b/src/core/src/NIActions.h index 460ec3624..710e4aa8b 100644 --- a/src/core/src/NIActions.h +++ b/src/core/src/NIActions.h @@ -29,7 +29,7 @@ * @param target The target that was attached to the NIActions instance. * @param indexPath The index path of the object. */ -typedef BOOL (^NIActionBlock)(id object, id target, NSIndexPath* indexPath); +typedef BOOL (^NIActionBlock)(_Nonnull id object, _Nonnull id target, NSIndexPath* _Nonnull indexPath); /** * The attachable types of actions for NIAction. @@ -92,34 +92,34 @@ NSArray *objects = @[ @interface NIActions : NSObject // Designated initializer. -- (id)initWithTarget:(id)target; +- (nonnull id)initWithTarget:(nullable id)target; #pragma mark Mapping Objects -- (id)attachToObject:(id)object tapBlock:(NIActionBlock)action; -- (id)attachToObject:(id)object detailBlock:(NIActionBlock)action; -- (id)attachToObject:(id)object navigationBlock:(NIActionBlock)action; +- (nonnull id)attachToObject:(nonnull id)object tapBlock:(nonnull NIActionBlock)action; +- (nonnull id)attachToObject:(nonnull id)object detailBlock:(nonnull NIActionBlock)action; +- (nonnull id)attachToObject:(nonnull id)object navigationBlock:(nonnull NIActionBlock)action; -- (id)attachToObject:(id)object tapSelector:(SEL)selector; -- (id)attachToObject:(id)object detailSelector:(SEL)selector; -- (id)attachToObject:(id)object navigationSelector:(SEL)selector; +- (nonnull id)attachToObject:(nonnull id)object tapSelector:(nonnull SEL)selector; +- (nonnull id)attachToObject:(nonnull id)object detailSelector:(nonnull SEL)selector; +- (nonnull id)attachToObject:(nonnull id)object navigationSelector:(nonnull SEL)selector; #pragma mark Mapping Classes -- (void)attachToClass:(Class)aClass tapBlock:(NIActionBlock)action; -- (void)attachToClass:(Class)aClass detailBlock:(NIActionBlock)action; -- (void)attachToClass:(Class)aClass navigationBlock:(NIActionBlock)action; +- (void)attachToClass:(nonnull Class)aClass tapBlock:(nonnull NIActionBlock)action; +- (void)attachToClass:(nonnull Class)aClass detailBlock:(nonnull NIActionBlock)action; +- (void)attachToClass:(nonnull Class)aClass navigationBlock:(nonnull NIActionBlock)action; -- (void)attachToClass:(Class)aClass tapSelector:(SEL)selector; -- (void)attachToClass:(Class)aClass detailSelector:(SEL)selector; -- (void)attachToClass:(Class)aClass navigationSelector:(SEL)selector; +- (void)attachToClass:(nonnull Class)aClass tapSelector:(nonnull SEL)selector; +- (void)attachToClass:(nonnull Class)aClass detailSelector:(nonnull SEL)selector; +- (void)attachToClass:(nonnull Class)aClass navigationSelector:(nonnull SEL)selector; #pragma mark Object State -- (BOOL)isObjectActionable:(id)object; -- (NIActionType)attachedActionTypesForObject:(id)object; +- (BOOL)isObjectActionable:(nonnull id)object; +- (NIActionType)attachedActionTypesForObject:(nonnull id)object; -+ (id)objectFromKeyClass:(Class)keyClass map:(NSMutableDictionary *)map; ++ (nullable id)objectFromKeyClass:(nonnull Class)keyClass map:(nonnull NSMutableDictionary *)map; @end @@ -137,7 +137,7 @@ extern "C" { * * @param controllerClass The class of controller to instantiate. */ -NIActionBlock NIPushControllerAction(Class controllerClass); +_Nonnull NIActionBlock NIPushControllerAction(_Nonnull Class controllerClass); #if defined __cplusplus } @@ -151,7 +151,7 @@ NIActionBlock NIPushControllerAction(Class controllerClass); * * @param indexPath The index path of the requested object. */ -- (id)objectAtIndexPath:(NSIndexPath *)indexPath; +- (nullable id)objectAtIndexPath:(nonnull NSIndexPath *)indexPath; @end From 5449048b50c47dc18a2a5c6b8859fcd542b50679 Mon Sep 17 00:00:00 2001 From: featherless Date: Sun, 3 Nov 2019 19:36:35 -0500 Subject: [PATCH 2/2] Update NIActions.h --- src/core/src/NIActions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/src/NIActions.h b/src/core/src/NIActions.h index 710e4aa8b..c8459f43c 100644 --- a/src/core/src/NIActions.h +++ b/src/core/src/NIActions.h @@ -29,7 +29,7 @@ * @param target The target that was attached to the NIActions instance. * @param indexPath The index path of the object. */ -typedef BOOL (^NIActionBlock)(_Nonnull id object, _Nonnull id target, NSIndexPath* _Nonnull indexPath); +typedef BOOL (^NIActionBlock)(_Nonnull id object, _Nullable id target, NSIndexPath* _Nonnull indexPath); /** * The attachable types of actions for NIAction.