From cfac6c992ac95593654b31a0f6573ab7bfcab24b Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 10 Jul 2015 19:02:04 +0700 Subject: [PATCH 1/6] [appledoc] Fix appledoc warnings. (#553) --- AsyncDisplayKit/ASCollectionView.h | 22 +++++++++---- AsyncDisplayKit/ASControlNode.h | 9 +++++- AsyncDisplayKit/ASDisplayNode+Subclasses.h | 4 +++ AsyncDisplayKit/ASDisplayNode.h | 22 ++++++++++--- AsyncDisplayKit/ASEditableTextNode.h | 9 ++++-- AsyncDisplayKit/ASMultiplexImageNode.h | 8 +++++ AsyncDisplayKit/ASNetworkImageNode.h | 6 ++++ AsyncDisplayKit/ASTableView.h | 9 +++++- AsyncDisplayKit/Details/ASDataController.h | 2 +- AsyncDisplayKit/Details/ASRangeController.h | 36 +++++++++++++++++++++ 10 files changed, 111 insertions(+), 16 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index ec6fd324..8254a95b 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -31,11 +31,11 @@ @property (nonatomic, weak) id asyncDelegate; // must not be nil /** - * Tuning parameters for a range. + * Tuning parameters for a range type. * - * @param range The range to get the tuning parameters for. + * @param rangeType The range type to get the tuning parameters for. * - * @returns A tuning parameter value for the given range. + * @returns A tuning parameter value for the given range type. * * Defaults to the render range having one sceenful both leading and trailing and the preload range having two * screenfuls in both directions. @@ -43,16 +43,24 @@ - (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType; /** - * Set the tuning parameters for a range. + * Set the tuning parameters for a range type. * - * @param tuningParameters The tuning parameters to store for a range. - * @param range The range to set the tuning parameters for. + * @param tuningParameters The tuning parameters to store for a range type. + * @param rangeType The range type to set the tuning parameters for. */ - (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType; /** * Initializer. * + * @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview + * in which you plan to add it. This frame is passed to the superclass during initialization. + * + * @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. + * Must not be nil. + * + * @param asyncDataFetchingEnabled Enable the data fetching in async mode. + * * @discussion If asyncDataFetching is enabled, the `AScollectionView` will fetch data through `collectionView:numberOfRowsInSection:` and * `collectionView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically * from calling thread. @@ -156,7 +164,7 @@ /** * Similar to -collectionView:cellForItemAtIndexPath:. * - * @param collection The sender. + * @param collectionView The sender. * * @param indexPath The index path of the requested node. * diff --git a/AsyncDisplayKit/ASControlNode.h b/AsyncDisplayKit/ASControlNode.h index b94bb772..d08a09c6 100644 --- a/AsyncDisplayKit/ASControlNode.h +++ b/AsyncDisplayKit/ASControlNode.h @@ -15,14 +15,21 @@ */ typedef NS_OPTIONS(NSUInteger, ASControlNodeEvent) { + /** A touch-down event in the control node. */ ASControlNodeEventTouchDown = 1 << 0, + /** A repeated touch-down event in the control node; for this event the value of the UITouch tapCount method is greater than one. */ ASControlNodeEventTouchDownRepeat = 1 << 1, + /** An event where a finger is dragged inside the bounds of the control node. */ ASControlNodeEventTouchDragInside = 1 << 2, + /** An event where a finger is dragged just outside the bounds of the control. */ ASControlNodeEventTouchDragOutside = 1 << 3, + /** A touch-up event in the control node where the finger is inside the bounds of the node. */ ASControlNodeEventTouchUpInside = 1 << 4, + /** A touch-up event in the control node where the finger is outside the bounds of the node. */ ASControlNodeEventTouchUpOutside = 1 << 5, + /** A system event canceling the current touches for the control node. */ ASControlNodeEventTouchCancel = 1 << 6, - + /** All events, including system events. */ ASControlNodeEventAllEvents = 0xFFFFFFFF }; diff --git a/AsyncDisplayKit/ASDisplayNode+Subclasses.h b/AsyncDisplayKit/ASDisplayNode+Subclasses.h index fec0527f..745b0c32 100644 --- a/AsyncDisplayKit/ASDisplayNode+Subclasses.h +++ b/AsyncDisplayKit/ASDisplayNode+Subclasses.h @@ -267,6 +267,8 @@ * @abstract Indicates that the receiver is about to display its subnodes. This method is not called if there are no * subnodes present. * + * @param subnode The subnode of which display is about to begin. + * * @discussion Subclasses may override this method to be notified when subnode display (asynchronous or synchronous) is * about to begin. */ @@ -276,6 +278,8 @@ * @abstract Indicates that the receiver is finished displaying its subnodes. This method is not called if there are * no subnodes present. * + * @param subnode The subnode of which display is about to completed. + * * @discussion Subclasses may override this method to be notified when subnode display (asynchronous or synchronous) has * completed. */ diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index bd0c5727..efa17d52 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -13,7 +13,13 @@ #import #import +/** + * UIView creation block. Used to create the backing view of a new display node. + */ typedef UIView *(^ASDisplayNodeViewBlock)(); +/** + * CALayer creation block. Used to create the backing layer of a new display node. + */ typedef CALayer *(^ASDisplayNodeLayerBlock)(); /** @@ -50,6 +56,8 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); /** * @abstract Alternative initializer with a block to create the backing view. * + * @param viewBlock The block that will be used to create the backing view. + * * @return An ASDisplayNode instance that loads its view with the given block that is guaranteed to run on the main * queue. The view will render synchronously and -layout and touch handling methods on the node will not be called. */ @@ -58,6 +66,8 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); /** * @abstract Alternative initializer with a block to create the backing layer. * + * @param viewBlock The block that will be used to create the backing layer. + * * @return An ASDisplayNode instance that loads its layer with the given block that is guaranteed to run on the main * queue. The layer will render synchronously and -layout and touch handling methods on the node will not be called. */ @@ -332,7 +342,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * This method is used to notify the node that it should purge any content that is both expensive to fetch and to * retain in memory. * - * @see clearFetchedData and fetchData + * @see ASDisplayNode(Subclassing):clearFetchedData and fetchData */ - (void)recursivelyClearFetchedData; @@ -341,7 +351,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * * @discussion Fetches content from remote sources for the current node and all subnodes. * - * @see fetchData and clearFetchedData + * @see ASDisplayNode(Subclassing):fetchData and clearFetchedData */ - (void)recursivelyFetchData; @@ -556,18 +566,22 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); @interface ASDisplayNode (ASDisplayNodeAsyncTransactionContainer) @end - +/** UIVIew(AsyncDisplayKit) defines convenience method for adding sub-ASDisplayNode to an UIView. */ @interface UIView (AsyncDisplayKit) /** * Convenience method, equivalent to [view addSubview:node.view] or [view.layer addSublayer:node.layer] if layer-backed. + * + * @param node The node to be added. */ - (void)addSubnode:(ASDisplayNode *)node; @end - +/** CALayer(AsyncDisplayKit) defines convenience method for adding sub-ASDisplayNode to a CALayer. */ @interface CALayer (AsyncDisplayKit) /** * Convenience method, equivalent to [layer addSublayer:node.layer]. + * + * @param node The node to be added. */ - (void)addSubnode:(ASDisplayNode *)node; @end diff --git a/AsyncDisplayKit/ASEditableTextNode.h b/AsyncDisplayKit/ASEditableTextNode.h index 92811e24..fb3354c8 100644 --- a/AsyncDisplayKit/ASEditableTextNode.h +++ b/AsyncDisplayKit/ASEditableTextNode.h @@ -11,10 +11,10 @@ @protocol ASEditableTextNodeDelegate; -//! @abstract ASEditableTextNode implements a node that supports text editing. +/// @abstract ASEditableTextNode implements a node that supports text editing. @interface ASEditableTextNode : ASDisplayNode -//! @abstract The text node's delegate, which must conform to the protocol. +// @abstract The text node's delegate, which must conform to the protocol. @property (nonatomic, readwrite, weak) id delegate; #pragma mark - Configuration @@ -74,6 +74,11 @@ @end #pragma mark - +/** + * The methods declared by the ASEditableTextNodeDelegate protocol allow the adopting delegate to + * respond to notifications such as began and finished editing, selection changed and text updated; + * and manage whether a specified text should be replaced. + */ @protocol ASEditableTextNodeDelegate @optional diff --git a/AsyncDisplayKit/ASMultiplexImageNode.h b/AsyncDisplayKit/ASMultiplexImageNode.h index c62f7c31..db10daa3 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.h +++ b/AsyncDisplayKit/ASMultiplexImageNode.h @@ -102,6 +102,10 @@ typedef NS_ENUM(NSUInteger, ASMultiplexImageNodeErrorCode) { #pragma mark - +/** + * The methods declared by the ASMultiplexImageNodeDelegate protocol allow the adopting delegate to respond to + * notifications such as began, progressed and finished downloading, updated and displayed an image. + */ @protocol ASMultiplexImageNodeDelegate @optional @@ -170,6 +174,10 @@ didFinishDownloadingImageWithIdentifier:(id)imageIdentifier #pragma mark - +/** + * The ASMultiplexImageNodeDataSource protocol is adopted by an object that provides the multiplex image node, + * for each image identifier, an image or a URL the image node should load. + */ @protocol ASMultiplexImageNodeDataSource @optional diff --git a/AsyncDisplayKit/ASNetworkImageNode.h b/AsyncDisplayKit/ASNetworkImageNode.h index 7039004c..5dc72352 100644 --- a/AsyncDisplayKit/ASNetworkImageNode.h +++ b/AsyncDisplayKit/ASNetworkImageNode.h @@ -61,6 +61,8 @@ /** * Download and display a new image. * + * @param URL The URL of a new image to download and display. + * * @param reset Whether to display a placeholder () while loading the new image. */ - (void)setURL:(NSURL *)URL resetToDefault:(BOOL)reset; @@ -74,6 +76,10 @@ #pragma mark - +/** + * The methods declared by the ASNetworkImageNodeDelegate protocol allow the adopting delegate to respond to + * notifications such as fininished decoding and downloading an image. + */ @protocol ASNetworkImageNodeDelegate /** diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index 8b399a01..1e0534c8 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -51,7 +51,14 @@ - (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType; /** - * initializer. + * Initializer. + * + * @param frame A rectangle specifying the initial location and size of the table view in its superview’€™s coordinates. + * The frame of the table view changes as table cells are added and deleted. + * + * @param style A constant that specifies the style of the table view. See UITableViewStyle for descriptions of valid constants. + * + * @param asyncDataFetchingEnabled Enable the data fetching in async mode. * * @discussion If asyncDataFetching is enabled, the `ASTableView` will fetch data through `tableView:numberOfRowsInSection:` and * `tableView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically diff --git a/AsyncDisplayKit/Details/ASDataController.h b/AsyncDisplayKit/Details/ASDataController.h index 08dfd4fb..5ec49b5c 100644 --- a/AsyncDisplayKit/Details/ASDataController.h +++ b/AsyncDisplayKit/Details/ASDataController.h @@ -111,7 +111,7 @@ typedef NSUInteger ASDataControllerAnimationOptions; @property (nonatomic, weak) id delegate; /** - * Designated iniailizer. + * Designated initializer. * * @param asyncDataFetchingEnabled Enable the data fetching in async mode. * diff --git a/AsyncDisplayKit/Details/ASRangeController.h b/AsyncDisplayKit/Details/ASRangeController.h index cdfb0568..d8dd1bf5 100644 --- a/AsyncDisplayKit/Details/ASRangeController.h +++ b/AsyncDisplayKit/Details/ASRangeController.h @@ -30,6 +30,8 @@ * Notify the range controller that the visible range has been updated. * This is the primary input call that drives updating the working ranges, and triggering their actions. * + * @param scrollDirection The current scroll direction of the scroll view. + * * @see [ASRangeControllerDelegate rangeControllerVisibleNodeIndexPaths:] */ - (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection; @@ -74,36 +76,70 @@ /** * Begin updates. + * + * @param rangeController Sender. */ - (void)rangeControllerBeginUpdates:(ASRangeController *)rangeController; /** * End updates. + * + * @param rangeController Sender. + * + * @param completion Completion block. */ - (void)rangeControllerEndUpdates:(ASRangeController * )rangeController completion:(void (^)(BOOL))completion ; /** * Fetch nodes at specific index paths. + * + * @param rangeController Sender. + * + * @param indexPaths Index paths. */ - (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths; /** * Called for nodes insertion. + * + * @param rangeController Sender. + * + * @param indexPaths Index path of inserted nodes. + * + * @param animationOptions Animation options. See ASDataControllerAnimationOptions. */ - (void)rangeController:(ASRangeController *)rangeController didInsertNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions; /** * Called for nodes deletion. + * + * @param rangeController Sender. + * + * @param indexPaths Index path of deleted nodes. + * + * @param animationOptions Animation options. See ASDataControllerAnimationOptions. */ - (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions; /** * Called for section insertion. + * + * @param rangeController Sender. + * + * @param indexSet Index set of inserted sections. + * + * @param animationOptions Animation options. See ASDataControllerAnimationOptions. */ - (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions; /** * Called for section deletion. + * + * @param rangeController Sender. + * + * @param indexSet Index set of deleted sections. + * + * @param animationOptions Animation options. See ASDataControllerAnimationOptions. */ - (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions; From e1fd58268c8643770ffd047a80bf1264a4ab6e33 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 10 Jul 2015 11:28:43 +0700 Subject: [PATCH 2/6] Clean up #468: - -layoutSpecThatFits: must return an ASLayoutSpec. - Move ASDisplayNode's -measureWithSizeRange: redeclaration to ASDisplayNode.h. - Rename ASStackLayoutChild.h to ASStackLayoutDefines.h. - Rename ASStaticLayoutSpecDimension.h to ASRelativeSize.h. - Don't import ASLayout.h in other headers to prevent circular inclusions. - Explain use cases of ASLayout's initializers. - Clean up ASInternalHelpers.h. --- AsyncDisplayKit.xcodeproj/project.pbxproj | 24 +++++++++---------- AsyncDisplayKit/ASCellNode.m | 2 +- AsyncDisplayKit/ASDisplayNode+Subclasses.h | 24 +++---------------- AsyncDisplayKit/ASDisplayNode.h | 21 +++++++++++++++- AsyncDisplayKit/ASDisplayNode.mm | 6 +++-- AsyncDisplayKit/AsyncDisplayKit.h | 2 +- .../Layout/ASBackgroundLayoutSpec.mm | 1 + AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm | 1 + AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm | 1 + AsyncDisplayKit/Layout/ASLayout.h | 9 +++++-- AsyncDisplayKit/Layout/ASLayoutSpec.h | 1 - AsyncDisplayKit/Layout/ASLayoutable.h | 2 +- AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm | 1 + AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm | 1 + ...LayoutSpecDimension.h => ASRelativeSize.h} | 0 ...youtSpecDimension.mm => ASRelativeSize.mm} | 2 +- ...ckLayoutChild.h => ASStackLayoutDefines.h} | 0 AsyncDisplayKit/Layout/ASStaticLayoutSpec.h | 2 +- AsyncDisplayKit/Layout/ASStaticLayoutSpec.mm | 1 + .../Private/ASDisplayNodeInternal.h | 1 - AsyncDisplayKit/Private/ASInternalHelpers.h | 4 +--- .../ASLayoutSpecSnapshotTestsHelper.m | 1 + 22 files changed, 59 insertions(+), 48 deletions(-) rename AsyncDisplayKit/Layout/{ASStaticLayoutSpecDimension.h => ASRelativeSize.h} (100%) rename AsyncDisplayKit/Layout/{ASStaticLayoutSpecDimension.mm => ASRelativeSize.mm} (98%) rename AsyncDisplayKit/Layout/{ASStackLayoutChild.h => ASStackLayoutDefines.h} (100%) diff --git a/AsyncDisplayKit.xcodeproj/project.pbxproj b/AsyncDisplayKit.xcodeproj/project.pbxproj index 7404eefa..3cab5c82 100644 --- a/AsyncDisplayKit.xcodeproj/project.pbxproj +++ b/AsyncDisplayKit.xcodeproj/project.pbxproj @@ -187,13 +187,13 @@ 509E68661B3AEDD7009B9150 /* CGRect+ASConvenience.m in Sources */ = {isa = PBXBuildFile; fileRef = 205F0E201B376416007741D0 /* CGRect+ASConvenience.m */; }; 6BDC61F61979037800E50D21 /* AsyncDisplayKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9F06E5CD1B4CAF4200F015D8 /* ASCollectionViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F06E5CC1B4CAF4200F015D8 /* ASCollectionViewTests.m */; }; - AC21EC101B3D0BF600C8B19A /* ASStackLayoutChild.h in Headers */ = {isa = PBXBuildFile; fileRef = AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutChild.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AC21EC101B3D0BF600C8B19A /* ASStackLayoutDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutDefines.h */; settings = {ATTRIBUTES = (Public, ); }; }; AC3C4A511A1139C100143C57 /* ASCollectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = AC3C4A4F1A1139C100143C57 /* ASCollectionView.h */; settings = {ATTRIBUTES = (Public, ); }; }; AC3C4A521A1139C100143C57 /* ASCollectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC3C4A501A1139C100143C57 /* ASCollectionView.mm */; }; AC3C4A541A113EEC00143C57 /* ASCollectionViewProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = AC3C4A531A113EEC00143C57 /* ASCollectionViewProtocols.h */; settings = {ATTRIBUTES = (Public, ); }; }; AC47D9421B3B891B00AAEE9D /* ASCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = AC6456071B0A335000CF11B8 /* ASCellNode.m */; }; - AC47D9451B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.h in Headers */ = {isa = PBXBuildFile; fileRef = AC47D9431B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AC47D9461B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC47D9441B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.mm */; }; + AC47D9451B3BB41900AAEE9D /* ASRelativeSize.h in Headers */ = {isa = PBXBuildFile; fileRef = AC47D9431B3BB41900AAEE9D /* ASRelativeSize.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AC47D9461B3BB41900AAEE9D /* ASRelativeSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC47D9441B3BB41900AAEE9D /* ASRelativeSize.mm */; }; AC6456091B0A335000CF11B8 /* ASCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = AC6456071B0A335000CF11B8 /* ASCellNode.m */; }; ACF6ED1A1B17843500DA7C62 /* ASBackgroundLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED011B17843500DA7C62 /* ASBackgroundLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; }; ACF6ED1B1B17843500DA7C62 /* ASBackgroundLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED021B17843500DA7C62 /* ASBackgroundLayoutSpec.mm */; }; @@ -526,12 +526,12 @@ 4640521F1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMultidimensionalArrayUtils.mm; sourceTree = ""; }; 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AsyncDisplayKit.h; sourceTree = ""; }; 9F06E5CC1B4CAF4200F015D8 /* ASCollectionViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCollectionViewTests.m; sourceTree = ""; }; - AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASStackLayoutChild.h; path = AsyncDisplayKit/Layout/ASStackLayoutChild.h; sourceTree = ""; }; + AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASStackLayoutDefines.h; path = AsyncDisplayKit/Layout/ASStackLayoutDefines.h; sourceTree = ""; }; AC3C4A4F1A1139C100143C57 /* ASCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCollectionView.h; sourceTree = ""; }; AC3C4A501A1139C100143C57 /* ASCollectionView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCollectionView.mm; sourceTree = ""; }; AC3C4A531A113EEC00143C57 /* ASCollectionViewProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCollectionViewProtocols.h; sourceTree = ""; }; - AC47D9431B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASStaticLayoutSpecDimension.h; path = AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.h; sourceTree = ""; }; - AC47D9441B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASStaticLayoutSpecDimension.mm; path = AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.mm; sourceTree = ""; }; + AC47D9431B3BB41900AAEE9D /* ASRelativeSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRelativeSize.h; path = AsyncDisplayKit/Layout/ASRelativeSize.h; sourceTree = ""; }; + AC47D9441B3BB41900AAEE9D /* ASRelativeSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASRelativeSize.mm; path = AsyncDisplayKit/Layout/ASRelativeSize.mm; sourceTree = ""; }; AC6456071B0A335000CF11B8 /* ASCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCellNode.m; sourceTree = ""; }; ACF6ED011B17843500DA7C62 /* ASBackgroundLayoutSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASBackgroundLayoutSpec.h; path = AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.h; sourceTree = ""; }; ACF6ED021B17843500DA7C62 /* ASBackgroundLayoutSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASBackgroundLayoutSpec.mm; path = AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm; sourceTree = ""; }; @@ -914,6 +914,8 @@ ACF6ED041B17843500DA7C62 /* ASCenterLayoutSpec.mm */, ACF6ED071B17843500DA7C62 /* ASDimension.h */, ACF6ED081B17843500DA7C62 /* ASDimension.mm */, + AC47D9431B3BB41900AAEE9D /* ASRelativeSize.h */, + AC47D9441B3BB41900AAEE9D /* ASRelativeSize.mm */, ACF6ED091B17843500DA7C62 /* ASInsetLayoutSpec.h */, ACF6ED0A1B17843500DA7C62 /* ASInsetLayoutSpec.mm */, ACF6ED0B1B17843500DA7C62 /* ASLayout.h */, @@ -925,13 +927,11 @@ ACF6ED131B17843500DA7C62 /* ASOverlayLayoutSpec.mm */, ACF6ED141B17843500DA7C62 /* ASRatioLayoutSpec.h */, ACF6ED151B17843500DA7C62 /* ASRatioLayoutSpec.mm */, - AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutChild.h */, + AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutDefines.h */, ACF6ED161B17843500DA7C62 /* ASStackLayoutSpec.h */, ACF6ED171B17843500DA7C62 /* ASStackLayoutSpec.mm */, ACF6ED181B17843500DA7C62 /* ASStaticLayoutSpec.h */, ACF6ED191B17843500DA7C62 /* ASStaticLayoutSpec.mm */, - AC47D9431B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.h */, - AC47D9441B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.mm */, ); name = Layout; path = ..; @@ -971,8 +971,8 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - AC21EC101B3D0BF600C8B19A /* ASStackLayoutChild.h in Headers */, - AC47D9451B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.h in Headers */, + AC21EC101B3D0BF600C8B19A /* ASStackLayoutDefines.h in Headers */, + AC47D9451B3BB41900AAEE9D /* ASRelativeSize.h in Headers */, ACF6ED511B17847A00DA7C62 /* ASStackUnpositionedLayout.h in Headers */, ACF6ED2D1B17843500DA7C62 /* ASRatioLayoutSpec.h in Headers */, ACF6ED261B17843500DA7C62 /* ASLayoutSpec.h in Headers */, @@ -1374,7 +1374,7 @@ ACF6ED1B1B17843500DA7C62 /* ASBackgroundLayoutSpec.mm in Sources */, 055F1A3519ABD3E3004DAFF1 /* ASTableView.mm in Sources */, 205F0E121B371BD7007741D0 /* ASScrollDirection.m in Sources */, - AC47D9461B3BB41900AAEE9D /* ASStaticLayoutSpecDimension.mm in Sources */, + AC47D9461B3BB41900AAEE9D /* ASRelativeSize.mm in Sources */, ACF6ED271B17843500DA7C62 /* ASLayoutSpec.mm in Sources */, ACF6ED211B17843500DA7C62 /* ASDimension.mm in Sources */, 464052261A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm in Sources */, diff --git a/AsyncDisplayKit/ASCellNode.m b/AsyncDisplayKit/ASCellNode.m index 39aadab6..4273a10c 100644 --- a/AsyncDisplayKit/ASCellNode.m +++ b/AsyncDisplayKit/ASCellNode.m @@ -106,7 +106,7 @@ static const CGFloat kFontSize = 18.0f; return self; } -- (id)layoutSpecThatFits:(ASSizeRange)constrainedSize +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { static const CGFloat kHorizontalPadding = 15.0f; static const CGFloat kVerticalPadding = 11.0f; diff --git a/AsyncDisplayKit/ASDisplayNode+Subclasses.h b/AsyncDisplayKit/ASDisplayNode+Subclasses.h index fec0527f..34cb3dfa 100644 --- a/AsyncDisplayKit/ASDisplayNode+Subclasses.h +++ b/AsyncDisplayKit/ASDisplayNode+Subclasses.h @@ -13,8 +13,7 @@ #import #import -#import -#import +@class ASLayoutSpec; /** * The subclass header _ASDisplayNode+Subclasses_ defines the following methods that either must or can be overriden by @@ -36,7 +35,7 @@ * variables. */ -@interface ASDisplayNode (Subclassing) +@interface ASDisplayNode (Subclassing) /** @name View Configuration */ @@ -120,23 +119,6 @@ /** @name Layout calculation */ -/** - * @abstract Asks the node to measure a layout based on given size range. - * - * @param constrainedSize The minimum and maximum sizes the receiver should fit in. - * - * @return An ASLayout instance defining the layout of the receiver (and its children, if the box layout model is used). - * - * @discussion Though this method does not set the bounds of the view, it does have side effects--caching both the - * constraint and the result. - * - * @warning Subclasses must not override this; it caches results from -calculateLayoutThatFits:. Calling this method may - * be expensive if result is not cached. - * - * @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:] - */ -- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize; - /** * @abstract Calculate a layout based on given size range. * @@ -180,7 +162,7 @@ * * @note This method should not be called directly outside of ASDisplayNode; use -measure: or -calculatedLayout instead. */ -- (id)layoutSpecThatFits:(ASSizeRange)constrainedSize; +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize; /** * @abstract Invalidate previously measured and cached layout. diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index bd0c5727..4fbd3281 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -13,6 +13,8 @@ #import #import +#import + typedef UIView *(^ASDisplayNodeViewBlock)(); typedef CALayer *(^ASDisplayNodeLayerBlock)(); @@ -32,7 +34,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * */ -@interface ASDisplayNode : ASDealloc2MainObject +@interface ASDisplayNode : ASDealloc2MainObject /** @name Initializing a node object */ @@ -137,6 +139,23 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); */ - (CGSize)measure:(CGSize)constrainedSize; +/** + * @abstract Asks the node to measure a layout based on given size range. + * + * @param constrainedSize The minimum and maximum sizes the receiver should fit in. + * + * @return An ASLayout instance defining the layout of the receiver (and its children, if the box layout model is used). + * + * @discussion Though this method does not set the bounds of the view, it does have side effects--caching both the + * constraint and the result. + * + * @warning Subclasses must not override this; it caches results from -calculateLayoutThatFits:. Calling this method may + * be expensive if result is not cached. + * + * @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:] + */ +- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize; + /** * @abstract Return the calculated size. * diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index bf81cdc9..43dbc037 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -19,6 +19,8 @@ #import "ASDisplayNodeExtras.h" #import "ASInternalHelpers.h" +#import "ASLayout.h" +#import "ASLayoutSpec.h" @interface ASDisplayNode () @@ -1307,10 +1309,10 @@ static NSInteger incrementIfFound(NSInteger i) { return CGSizeZero; } -- (id)layoutSpecThatFits:(ASSizeRange)constrainedSize +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { ASDisplayNodeAssertThreadAffinity(self); - return nil; + return [ASLayoutSpec new]; } - (ASLayout *)calculatedLayout diff --git a/AsyncDisplayKit/AsyncDisplayKit.h b/AsyncDisplayKit/AsyncDisplayKit.h index 46b3677f..b65d144f 100644 --- a/AsyncDisplayKit/AsyncDisplayKit.h +++ b/AsyncDisplayKit/AsyncDisplayKit.h @@ -35,5 +35,5 @@ #import #import #import -#import +#import #import diff --git a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm index 135fc372..ae03e788 100644 --- a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm @@ -12,6 +12,7 @@ #import "ASAssert.h" #import "ASBaseDefines.h" +#import "ASLayout.h" @interface ASBackgroundLayoutSpec () { diff --git a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm index 0ef0f484..f96b3591 100644 --- a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm @@ -11,6 +11,7 @@ #import "ASCenterLayoutSpec.h" #import "ASInternalHelpers.h" +#import "ASLayout.h" @implementation ASCenterLayoutSpec { diff --git a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm index c5f30431..8db39757 100644 --- a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm @@ -14,6 +14,7 @@ #import "ASBaseDefines.h" #import "ASInternalHelpers.h" +#import "ASLayout.h" @interface ASInsetLayoutSpec () { diff --git a/AsyncDisplayKit/Layout/ASLayout.h b/AsyncDisplayKit/Layout/ASLayout.h index 5bdd2190..3cc51588 100644 --- a/AsyncDisplayKit/Layout/ASLayout.h +++ b/AsyncDisplayKit/Layout/ASLayout.h @@ -38,14 +38,19 @@ extern BOOL CGPointIsNull(CGPoint point); sublayouts:(NSArray *)sublayouts; /** - * Convenience that has CGPointNull position. + * Convenience that has CGPointNull position. + * Best used by ASDisplayNode subclasses that are manually creating a layout for -calculateLayoutThatFits:, + * or for ASLayoutSpec subclasses that are referencing the "self" level in the layout tree, + * or for creating a sublayout of which the position is yet to be determined. */ + (instancetype)newWithLayoutableObject:(id)layoutableObject size:(CGSize)size sublayouts:(NSArray *)sublayouts; /** - * Convenience that has CGPointNull position and no sublayouts. + * Convenience that has CGPointNull position and no sublayouts. + * Best used for creating a layout that has no sublayouts, and is either a root one + * or a sublayout of which the position is yet to be determined. */ + (instancetype)newWithLayoutableObject:(id)layoutableObject size:(CGSize)size; diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.h b/AsyncDisplayKit/Layout/ASLayoutSpec.h index 122033d0..c2602824 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.h @@ -9,7 +9,6 @@ */ #import -#import /** A layout spec is an immutable object that describes a layout, loosely inspired by React. */ @interface ASLayoutSpec : NSObject diff --git a/AsyncDisplayKit/Layout/ASLayoutable.h b/AsyncDisplayKit/Layout/ASLayoutable.h index 5fc091b1..ea0aceda 100644 --- a/AsyncDisplayKit/Layout/ASLayoutable.h +++ b/AsyncDisplayKit/Layout/ASLayoutable.h @@ -9,7 +9,7 @@ */ #import -#import +#import @class ASLayout; diff --git a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm index 074753f1..b478f699 100644 --- a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm @@ -12,6 +12,7 @@ #import "ASAssert.h" #import "ASBaseDefines.h" +#import "ASLayout.h" @implementation ASOverlayLayoutSpec { diff --git a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm index 103be815..2e358b53 100644 --- a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm @@ -17,6 +17,7 @@ #import "ASBaseDefines.h" #import "ASInternalHelpers.h" +#import "ASLayout.h" @implementation ASRatioLayoutSpec { diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.h b/AsyncDisplayKit/Layout/ASRelativeSize.h similarity index 100% rename from AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.h rename to AsyncDisplayKit/Layout/ASRelativeSize.h diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.mm b/AsyncDisplayKit/Layout/ASRelativeSize.mm similarity index 98% rename from AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.mm rename to AsyncDisplayKit/Layout/ASRelativeSize.mm index 4790cd15..0410bb5a 100644 --- a/AsyncDisplayKit/Layout/ASStaticLayoutSpecDimension.mm +++ b/AsyncDisplayKit/Layout/ASRelativeSize.mm @@ -8,7 +8,7 @@ * */ -#import "ASStaticLayoutSpecDimension.h" +#import "ASRelativeSize.h" #import "ASAssert.h" ASRelativeSizeRange const ASRelativeSizeRangeUnconstrained = {}; diff --git a/AsyncDisplayKit/Layout/ASStackLayoutChild.h b/AsyncDisplayKit/Layout/ASStackLayoutDefines.h similarity index 100% rename from AsyncDisplayKit/Layout/ASStackLayoutChild.h rename to AsyncDisplayKit/Layout/ASStackLayoutDefines.h diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h index 91497c2d..09815c64 100644 --- a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h @@ -9,7 +9,7 @@ */ #import -#import +#import @interface ASStaticLayoutSpecChild : NSObject diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.mm b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.mm index f7488a71..daf0971e 100644 --- a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.mm @@ -12,6 +12,7 @@ #import "ASLayoutSpecUtilities.h" #import "ASInternalHelpers.h" +#import "ASLayout.h" @implementation ASStaticLayoutSpecChild diff --git a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h index cded26c2..39ce7010 100644 --- a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h +++ b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h @@ -17,7 +17,6 @@ #import "ASDisplayNode.h" #import "ASSentinel.h" #import "ASThread.h" -#import "ASLayout.h" BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector); void ASDisplayNodePerformBlockOnMainThread(void (^block)()); diff --git a/AsyncDisplayKit/Private/ASInternalHelpers.h b/AsyncDisplayKit/Private/ASInternalHelpers.h index 4349eb01..c2549b26 100644 --- a/AsyncDisplayKit/Private/ASInternalHelpers.h +++ b/AsyncDisplayKit/Private/ASInternalHelpers.h @@ -8,11 +8,9 @@ * */ -#import +#include #import "ASBaseDefines.h" -@class ASLayoutChild; - ASDISPLAYNODE_EXTERN_C_BEGIN BOOL ASSubclassOverridesSelector(Class superclass, Class subclass, SEL selector); diff --git a/AsyncDisplayKitTests/ASLayoutSpecSnapshotTestsHelper.m b/AsyncDisplayKitTests/ASLayoutSpecSnapshotTestsHelper.m index c15b28f6..0141d225 100644 --- a/AsyncDisplayKitTests/ASLayoutSpecSnapshotTestsHelper.m +++ b/AsyncDisplayKitTests/ASLayoutSpecSnapshotTestsHelper.m @@ -12,6 +12,7 @@ #import "ASDisplayNode.h" #import "ASLayoutSpec.h" +#import "ASLayout.h" @interface ASTestNode : ASDisplayNode - (void)setLayoutSpecUnderTest:(ASLayoutSpec *)layoutSpecUnderTest sizeRange:(ASSizeRange)sizeRange; From bbadc9a1e9a7a4b9148891eae6ea274b83320c4d Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 10 Jul 2015 19:46:32 +0700 Subject: [PATCH 3/6] Update nodes in Kittens example to use new signature of layoutSpecThatFits:.. --- examples/Kittens/Sample/BlurbNode.m | 2 +- examples/Kittens/Sample/KittenNode.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Kittens/Sample/BlurbNode.m b/examples/Kittens/Sample/BlurbNode.m index c26cecac..1c646a25 100644 --- a/examples/Kittens/Sample/BlurbNode.m +++ b/examples/Kittens/Sample/BlurbNode.m @@ -74,7 +74,7 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName"; } #if UseAutomaticLayout -- (id)layoutSpecThatFits:(ASSizeRange)constrainedSize +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { return [ASInsetLayoutSpec diff --git a/examples/Kittens/Sample/KittenNode.mm b/examples/Kittens/Sample/KittenNode.mm index db435d40..7e321712 100644 --- a/examples/Kittens/Sample/KittenNode.mm +++ b/examples/Kittens/Sample/KittenNode.mm @@ -129,7 +129,7 @@ static const CGFloat kInnerPadding = 10.0f; } #if UseAutomaticLayout -- (id)layoutSpecThatFits:(ASSizeRange)constrainedSize +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { ASRatioLayoutSpec *imagePlaceholder = [ASRatioLayoutSpec newWithRatio:1.0 child:_imageNode]; imagePlaceholder.flexBasis = ASRelativeDimensionMakeWithPoints(kImageSize); From 4383e9ab2bf03ad100ddd17507a86e37217a2815 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Thu, 9 Jul 2015 12:31:32 -0400 Subject: [PATCH 4/6] releasing downloaded image when multiplex image node exits render range --- AsyncDisplayKit/ASMultiplexImageNode.mm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/AsyncDisplayKit/ASMultiplexImageNode.mm b/AsyncDisplayKit/ASMultiplexImageNode.mm index 0bc9c6e8..d32d3be0 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.mm +++ b/AsyncDisplayKit/ASMultiplexImageNode.mm @@ -139,6 +139,13 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent */ - (void)_downloadImageWithIdentifier:(id)imageIdentifier URL:(NSURL *)imageURL completion:(void (^)(UIImage *image, NSError *error))completionBlock; +/** + @abstract Returns a Boolean value indicating whether the downloaded image should be removed when clearing fetched data + @discussion Downloaded image data should only be cleared out if a cache is present + @return YES if an image cache is available; otherwise, NO. + */ +- (BOOL)_shouldClearFetchedImageData; + @end @implementation ASMultiplexImageNode @@ -173,11 +180,15 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent } } -- (void)displayWillStart +- (void)clearFetchedData { - [super displayWillStart]; - - [self fetchData]; + [super clearFetchedData]; + + if ([self _shouldClearFetchedImageData]) { + // setting this to nil makes the node fetch images the next time its display starts + _loadedImageIdentifier = nil; + self.image = nil; + } } - (void)fetchData @@ -626,4 +637,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent [self _loadNextImage]; } +- (BOOL)_shouldClearFetchedImageData { + return _cache != nil; +} + @end From 3992e9b09b2f668f2aff79a3e3ebaca91ae6be38 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Sun, 12 Jul 2015 12:33:37 +0700 Subject: [PATCH 5/6] [appledoc] Fix all remaining warnings. --- AsyncDisplayKit/ASCollectionView.h | 82 ++++++++++++++-- AsyncDisplayKit/ASDisplayNode.h | 6 +- AsyncDisplayKit/ASTableView.h | 94 +++++++++++++++++-- AsyncDisplayKit/Layout/ASCenterLayoutSpec.h | 11 ++- AsyncDisplayKit/Layout/ASDimension.h | 7 +- AsyncDisplayKit/Layout/ASLayout.h | 23 ++++- AsyncDisplayKit/Layout/ASLayoutable.h | 5 + AsyncDisplayKit/Layout/ASStackLayoutDefines.h | 4 + AsyncDisplayKit/Layout/ASStackLayoutSpec.h | 5 + AsyncDisplayKit/Layout/ASStaticLayoutSpec.h | 29 ++++-- 10 files changed, 237 insertions(+), 29 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 8254a95b..ed2526ff 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -95,25 +95,95 @@ - (void)reloadData; /** - * Section updating. + * Inserts one or more sections. * - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. + * @param sections An index set that specifies the sections to insert. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. */ - (void)insertSections:(NSIndexSet *)sections; + +/** + * Deletes one or more sections. + * + * @param sections An index set that specifies the sections to delete. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)deleteSections:(NSIndexSet *)sections; + +/** + * Reloads the specified sections. + * + * @param sections An index set that specifies the sections to reload. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)reloadSections:(NSIndexSet *)sections; + +/** + * Moves a section to a new location. + * + * @param section The index of the section to move. + * + * @param newSection The index that is the destination of the move for the section. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection; /** - * Items updating. + * Inserts items at the locations identified by an array of index paths. * - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. + * @param indexPaths An array of NSIndexPath objects, each representing an item index and section index that together identify an item. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. */ - (void)insertItemsAtIndexPaths:(NSArray *)indexPaths; + +/** + * Deletes the items specified by an array of index paths. + * + * @param indexPaths An array of NSIndexPath objects identifying the items to delete. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths; + +/** + * Reloads the specified items. + * + * @param indexPaths An array of NSIndexPath objects identifying the items to reload. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths; + +/** + * Moves the item at a specified location to a destination location. + * + * @param indexPath The index path identifying the item to move. + * + * @param newIndexPath The index path that is the destination of the move for the item. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI collection view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; /** diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index e67b1fc5..fa052b3d 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -144,7 +144,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * -measureWithSizeRange: caches results from -calculateLayoutThatFits:. Calling this method may * be expensive if result is not cached. * - * @see [ASDisplayNode(Subclassing) measureWithSizeRange:] + * @see measureWithSizeRange: * @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:] */ - (CGSize)measure:(CGSize)constrainedSize; @@ -361,7 +361,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * This method is used to notify the node that it should purge any content that is both expensive to fetch and to * retain in memory. * - * @see ASDisplayNode(Subclassing):clearFetchedData and fetchData + * @see [ASDisplayNode(Subclassing) clearFetchedData] and [ASDisplayNode(Subclassing) fetchData] */ - (void)recursivelyClearFetchedData; @@ -370,7 +370,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)(); * * @discussion Fetches content from remote sources for the current node and all subnodes. * - * @see ASDisplayNode(Subclassing):fetchData and clearFetchedData + * @see [ASDisplayNode(Subclassing) fetchData] and [ASDisplayNode(Subclassing) clearFetchedData] */ - (void)recursivelyFetchData; diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index 1e0534c8..f8d9a60f 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -103,25 +103,107 @@ - (void)endUpdates; /** - * Section updating. + * Inserts one or more sections, with an option to animate the insertion. * - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. + * @param sections An index set that specifies the sections to insert. + * + * @param animation A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. */ - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Deletes one or more sections, with an option to animate the deletion. + * + * @param sections An index set that specifies the sections to delete. + * + * @param animation A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Reloads the specified sections using a given animation effect. + * + * @param sections An index set that specifies the sections to reload. + * + * @param animation A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Moves a section to a new location. + * + * @param section The index of the section to move. + * + * @param newSection The index that is the destination of the move for the section. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection; /** - * Row updating. + * Inserts rows at the locations identified by an array of index paths, with an option to animate the insertion. * - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. + * @param indexPaths An array of NSIndexPath objects, each representing a row index and section index that together identify a row. + * + * @param animation A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. */ - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Deletes the rows specified by an array of index paths, with an option to animate the deletion. + * + * @param indexPaths An array of NSIndexPath objects identifying the rows to delete. + * + * @param animation A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Reloads the specified rows using a given animation effect. + * + * @param indexPaths An array of NSIndexPath objects identifying the rows to reload. + * + * @param animation A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; + +/** + * Moves the row at a specified location to a destination location. + * + * @param indexPath The index path identifying the row to move. + * + * @param newIndexPath The index path that is the destination of the move for the row. + * + * @discussion This operation is asynchronous and thread safe. You can call it from background thread (it is recommendated) + * and the UI table view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes + * before this method is called. + */ - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; /** diff --git a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h index 5afc7319..84e015ac 100644 --- a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h @@ -10,6 +10,7 @@ #import +/** How the child is centered within the spec. */ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecCenteringOptions) { /** The child is positioned in {0,0} relatively to the layout bounds */ ASCenterLayoutSpecCenteringNone = 0, @@ -21,6 +22,7 @@ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecCenteringOptions) { ASCenterLayoutSpecCenteringXY = ASCenterLayoutSpecCenteringX | ASCenterLayoutSpecCenteringY }; +/** How much space the spec will take up. */ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecSizingOptions) { /** The spec will take up the maximum size possible */ ASCenterLayoutSpecSizingOptionDefault, @@ -36,8 +38,13 @@ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecSizingOptions) { @interface ASCenterLayoutSpec : ASLayoutSpec /** - @param centeringOptions, see ASCenterLayoutSpecCenteringOptions. - @param child The child to center. + * Initializer. + * + * @param centeringOptions How the child is centered. + * + * @param sizingOptions How much space will be taken up. + * + * @param child The child to center. */ + (instancetype)newWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions diff --git a/AsyncDisplayKit/Layout/ASDimension.h b/AsyncDisplayKit/Layout/ASDimension.h index 6c11aa77..590f9486 100644 --- a/AsyncDisplayKit/Layout/ASDimension.h +++ b/AsyncDisplayKit/Layout/ASDimension.h @@ -13,14 +13,11 @@ /** A dimension relative to constraints to be provided in the future. - A RelativeDimension can be one of two types: - - "Points" - Just a number. It will always resolve to exactly this amount. This is the default type. - - "Percent" - Multiplied to a provided parent amount to resolve a final amount. */ typedef NS_ENUM(NSInteger, ASRelativeDimensionType) { + /** Just a number. It will always resolve to exactly this amount. This is the default type. */ ASRelativeDimensionTypePoints, + /** Multiplied to a provided parent amount to resolve a final amount. */ ASRelativeDimensionTypePercent, }; diff --git a/AsyncDisplayKit/Layout/ASLayout.h b/AsyncDisplayKit/Layout/ASLayout.h index 3cc51588..a3d32fed 100644 --- a/AsyncDisplayKit/Layout/ASLayout.h +++ b/AsyncDisplayKit/Layout/ASLayout.h @@ -32,16 +32,33 @@ extern BOOL CGPointIsNull(CGPoint point); */ @property (nonatomic, readonly) NSArray *sublayouts; +/** + * Initializer. + * + * @param layoutableObject The backing ASLayoutable object. + * + * @param size The size of this layout. + * + * @param position The posiion of this layout within its parent (if available). + * + * @param sublayouts Sublayouts belong to the new layout. + */ + (instancetype)newWithLayoutableObject:(id)layoutableObject size:(CGSize)size position:(CGPoint)position sublayouts:(NSArray *)sublayouts; /** - * Convenience that has CGPointNull position. + * Convenience initializer that has CGPointNull position. * Best used by ASDisplayNode subclasses that are manually creating a layout for -calculateLayoutThatFits:, * or for ASLayoutSpec subclasses that are referencing the "self" level in the layout tree, * or for creating a sublayout of which the position is yet to be determined. + * + * @param layoutableObject The backing ASLayoutable object. + * + * @param size The size of this layout. + * + * @param sublayouts Sublayouts belong to the new layout. */ + (instancetype)newWithLayoutableObject:(id)layoutableObject size:(CGSize)size @@ -51,6 +68,10 @@ extern BOOL CGPointIsNull(CGPoint point); * Convenience that has CGPointNull position and no sublayouts. * Best used for creating a layout that has no sublayouts, and is either a root one * or a sublayout of which the position is yet to be determined. + * + * @param layoutableObject The backing ASLayoutable object. + * + * @param size The size of this layout. */ + (instancetype)newWithLayoutableObject:(id)layoutableObject size:(CGSize)size; diff --git a/AsyncDisplayKit/Layout/ASLayoutable.h b/AsyncDisplayKit/Layout/ASLayoutable.h index ea0aceda..30bf7af5 100644 --- a/AsyncDisplayKit/Layout/ASLayoutable.h +++ b/AsyncDisplayKit/Layout/ASLayoutable.h @@ -13,6 +13,11 @@ @class ASLayout; +/** + * The ASLayoutable protocol declares a method for measuring the layout of an object. A class must implement the method + * so that instances of that class can be used to build layout trees. The protocol also provides information + * about how an object should be laid out within an ASStackLayoutSpec. + */ @protocol ASLayoutable /** diff --git a/AsyncDisplayKit/Layout/ASStackLayoutDefines.h b/AsyncDisplayKit/Layout/ASStackLayoutDefines.h index 040d8ac0..6663ad2a 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutDefines.h +++ b/AsyncDisplayKit/Layout/ASStackLayoutDefines.h @@ -15,8 +15,12 @@ typedef NS_ENUM(NSUInteger, ASStackLayoutAlignSelf) { /** Inherit alignment value from containing stack. */ ASStackLayoutAlignSelfAuto, + /** Align to start of cross axis */ ASStackLayoutAlignSelfStart, + /** Align with end of cross axis */ ASStackLayoutAlignSelfEnd, + /** Center on cross axis */ ASStackLayoutAlignSelfCenter, + /** Expand to fill cross axis */ ASStackLayoutAlignSelfStretch, }; diff --git a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h index 83322b8d..29f20603 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h @@ -10,8 +10,11 @@ #import +/** The direction children are stacked in */ typedef NS_ENUM(NSUInteger, ASStackLayoutDirection) { + /** Children are stacked vertically */ ASStackLayoutDirectionVertical, + /** Children are stacked horizontally */ ASStackLayoutDirectionHorizontal, }; @@ -34,6 +37,7 @@ typedef NS_ENUM(NSUInteger, ASStackLayoutJustifyContent) { ASStackLayoutJustifyContentEnd, }; +/** Orientation of children along cross axis */ typedef NS_ENUM(NSUInteger, ASStackLayoutAlignItems) { /** Align children to start of cross axis */ ASStackLayoutAlignItemsStart, @@ -68,6 +72,7 @@ typedef struct { justifyContent determines how children are laid out. For example: + - Suppose stacking direction is Vertical, min-width=100, max-width=300, min-height=200, max-height=500. - All children are laid out with min-width=100, max-width=300, min-height=0, max-height=INFINITY. - If the sum of the childrens' heights is less than 200, children with flexGrow are flexed larger. diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h index 09815c64..259c32c4 100644 --- a/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASStaticLayoutSpec.h @@ -11,6 +11,10 @@ #import #import +/** + * An ASStaticLayoutSpecChild object wraps an ASLayoutable object and provides position and size information, + * to be used as a child of an ASStaticLayoutSpec. + */ @interface ASStaticLayoutSpecChild : NSObject @property (nonatomic, readonly) CGPoint position; @@ -21,20 +25,33 @@ */ @property (nonatomic, readonly) ASRelativeSizeRange size; +/** + * Initializer. + * + * @param position The position of this child within its parent spec. + * + * @param layoutableObject The backing ASLayoutable object of this child. + * + * @param size The size range that this child's size is trstricted according to. + */ + (instancetype)newWithPosition:(CGPoint)position layoutableObject:(id)layoutableObject size:(ASRelativeSizeRange)size; /** - Convenience with default size is Unconstrained in both dimensions, which sets the child's min size to zero - and max size to the maximum available space it can consume without overflowing the spec's bounds. + * Convenience initializer with default size is Unconstrained in both dimensions, which sets the child's min size to zero + * and max size to the maximum available space it can consume without overflowing the spec's bounds. + * + * @param position The position of this child within its parent spec. + * + * @param layoutableObject The backing ASLayoutable object of this child. */ + (instancetype)newWithPosition:(CGPoint)position layoutableObject:(id)layoutableObject; @end -/* - A layout spec that positions children at fixed positions. - - Computes a size that is the union of all childrens' frames. +/** + * A layout spec that positions children at fixed positions. + * + * Computes a size that is the union of all childrens' frames. */ @interface ASStaticLayoutSpec : ASLayoutSpec From 8f83e1ae8cb96401e1e1b0a5a1b5908972ef54bb Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Sun, 12 Jul 2015 13:27:24 +0700 Subject: [PATCH 6/6] [appledoc] Should generate docs for layout headers. --- docs/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build.sh b/docs/build.sh index 6605748f..c532bb0d 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -HEADERS=`ls ../AsyncDisplayKit/*.h ../AsyncDisplayKit/Details/ASRangeController.h` +HEADERS=`ls ../AsyncDisplayKit/*.h ../AsyncDisplayKit/Details/ASRangeController.h ../AsyncDisplayKit/Layout/*.h` rm -rf htdocs appledoc