From b84be07776ce6d65cb064b278b7a26d3874de0e5 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Fri, 5 Aug 2016 06:33:59 -0700 Subject: [PATCH] Make child and children on ASLayoutSpec a property --- AsyncDisplayKit/Layout/ASLayoutSpec.h | 30 ++++++--------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.h b/AsyncDisplayKit/Layout/ASLayoutSpec.h index 97f9fe1ca8..72d5b2445c 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.h @@ -40,11 +40,12 @@ NS_ASSUME_NONNULL_BEGIN * only require a single child. * * For layout specs that require a known number of children (ASBackgroundLayoutSpec, for example) - * a subclass should use this method to set the "primary" child. This is actually the same as calling - * setChild:forIdentifier:0. All other children should be set by defining convenience methods - * that call setChild:forIdentifier behind the scenes. + * a subclass should use this method to set the "primary" child. It can then use setChild:forIdentifier: + * to set any other required children. Ideally a subclass would hide this from the user, and use the + * setChild:forIdentifier: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild + * property that behind the scenes is calling setChild:forIdentifier:. */ -- (void)setChild:(id)child; +@property (nullable, strong, nonatomic) id child; /** * Adds a child with the given identifier to this layout spec. @@ -76,21 +77,7 @@ NS_ASSUME_NONNULL_BEGIN * For good measure, in these layout specs it probably makes sense to define * setChild: and setChild:forIdentifier: methods to do something appropriate or to assert. */ -- (void)setChildren:(NSArray> *)children; - -/** - * Get child methods - * - * There is a corresponding "getChild" method for the above "setChild" methods. If a subclass - * has extra layoutable children, it is recommended to make a corresponding get method for that - * child. For example, the ASBackgroundLayoutSpec responds to backgroundChild. - * - * If a get method is called on a spec that doesn't make sense, then the standard is to assert. - * For example, calling children on an ASInsetLayoutSpec will assert. - */ - -/** Returns the child added to this layout spec using the default identifier. */ -- (nullable id)child; +@property (nullable, strong, nonatomic) NSArray> *children; /** * Returns the child added to this layout spec using the given index. @@ -99,11 +86,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable id)childForIndex:(NSUInteger)index; -/** - * Returns all children added to this layout spec. - */ -- (nullable NSArray> *)children; - @end @interface ASLayoutSpec (Debugging)