From e529ec27da7c961fcbc595517526e88e53816d27 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Wed, 21 Mar 2018 08:13:09 -0700 Subject: [PATCH] Use NS_RETURNS_RETAINED macro to save time (#843) * Use NS_RETURNS_RETAINED macro to save time * Update changelog and do the thing with the license headers --- CHANGELOG.md | 3 +- Source/ASDisplayNode.mm | 2 +- Source/ASMapNode.mm | 2 +- Source/ASMultiplexImageNode.h | 2 +- Source/ASMultiplexImageNode.mm | 2 +- Source/ASRunLoopQueue.h | 2 + Source/ASRunLoopQueue.mm | 4 +- Source/ASTextNode2.mm | 2 +- Source/Debug/AsyncDisplayKit+Debug.m | 6 +-- Source/Details/ASBasicImageDownloader.h | 1 + Source/Details/ASIntegerMap.h | 4 +- Source/Details/ASIntegerMap.mm | 6 +-- Source/Details/ASPINRemoteImageDownloader.h | 1 + Source/Details/ASPINRemoteImageDownloader.m | 2 +- Source/Details/ASPageTable.h | 6 +-- Source/Details/ASPageTable.m | 8 ++-- Source/Details/ASTraitCollection.h | 12 +++--- Source/Details/ASTraitCollection.m | 12 +++--- Source/Details/ASWeakProxy.h | 2 +- Source/Details/ASWeakProxy.m | 2 +- Source/Layout/ASAbsoluteLayoutSpec.h | 4 +- Source/Layout/ASAbsoluteLayoutSpec.mm | 4 +- Source/Layout/ASAsciiArtBoxCreator.m | 2 +- Source/Layout/ASBackgroundLayoutSpec.h | 2 +- Source/Layout/ASBackgroundLayoutSpec.mm | 2 +- Source/Layout/ASCenterLayoutSpec.h | 2 +- Source/Layout/ASCenterLayoutSpec.mm | 2 +- Source/Layout/ASCornerLayoutSpec.h | 2 +- Source/Layout/ASCornerLayoutSpec.mm | 2 +- Source/Layout/ASInsetLayoutSpec.h | 2 +- Source/Layout/ASInsetLayoutSpec.mm | 2 +- Source/Layout/ASLayout.h | 8 ++-- Source/Layout/ASLayout.mm | 8 ++-- Source/Layout/ASLayoutSpec.h | 4 +- Source/Layout/ASLayoutSpec.mm | 4 +- Source/Layout/ASOverlayLayoutSpec.h | 2 +- Source/Layout/ASOverlayLayoutSpec.mm | 2 +- Source/Layout/ASRatioLayoutSpec.h | 2 +- Source/Layout/ASRatioLayoutSpec.mm | 2 +- Source/Layout/ASRelativeLayoutSpec.h | 2 +- Source/Layout/ASRelativeLayoutSpec.mm | 2 +- Source/Layout/ASStackLayoutSpec.h | 10 ++--- Source/Layout/ASStackLayoutSpec.mm | 10 ++--- Source/Private/ASRectMap.h | 2 +- Source/Private/ASRectMap.mm | 2 +- .../TextExperiment/Component/ASTextInput.h | 28 ++++++++------ .../TextExperiment/Component/ASTextInput.m | 28 ++++++++------ .../TextExperiment/Component/ASTextLayout.h | 22 +++++++---- .../TextExperiment/Component/ASTextLayout.m | 22 +++++++---- .../TextExperiment/Component/ASTextLine.h | 20 ++++++---- .../TextExperiment/Component/ASTextLine.m | 22 +++++++---- .../TextExperiment/String/ASTextAttribute.h | 38 +++++++++++-------- .../TextExperiment/String/ASTextAttribute.m | 38 +++++++++++-------- Source/TextKit/ASTextKitComponents.h | 4 +- Source/TextKit/ASTextKitComponents.mm | 4 +- Source/TextKit/ASTextKitCoreTextAdditions.h | 2 +- Source/TextKit/ASTextKitCoreTextAdditions.m | 2 +- Source/UIImage+ASConvenience.h | 10 ++--- Source/UIImage+ASConvenience.m | 12 +++--- Source/_ASTransitionContext.h | 2 +- Source/_ASTransitionContext.m | 2 +- 61 files changed, 239 insertions(+), 184 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d91da24..cc3991080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,8 +35,9 @@ - Fix UIResponder handling with view backing ASDisplayNode. [Michael Schneider](https://github.com/maicki) [#789](https://github.com/TextureGroup/Texture/pull/789/) - Optimized thread-local storage by replacing pthread_specific with C11 thread-local variables. [Adlai Holler](https://github.com/Adlai-Holler) [#811](https://github.com/TextureGroup/Texture/pull/811/) - Fixed a thread-sanitizer warning in ASTextNode. [Adlai Holler](https://github.com/Adlai-Holler) [#830](https://github.com/TextureGroup/Texture/pull/830/) -- Fix ASTextNode2 handling background color incorrectly. [Adlai Holler](https://github.com/Adlai-Holler) [#831] (https://github.com/TextureGroup/Texture/pull/831/) +- Fix ASTextNode2 handling background color incorrectly. [Adlai Holler](https://github.com/Adlai-Holler) [#831](https://github.com/TextureGroup/Texture/pull/831/) - [NoCopyRendering] Improved performance & fixed image memory not being tagged in Instruments. [Adlai Holler](https://github.com/Adlai-Holler) [#833](https://github.com/TextureGroup/Texture/pull/833/) +- Use `NS_RETURNS_RETAINED` macro to make our methods a tiny bit faster. [Adlai Holler](https://github.com/Adlai-Holler) [#843](https://github.com/TextureGroup/Texture/pull/843/) ## 2.6 - [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon) diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index 26b8f91d8..60eea7fb2 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -462,7 +462,7 @@ - (void)_scheduleIvarsForMainDeallocation * * Result is of type NSValue<[Ivar]> */ -+ (NSValue * _Nonnull)_ivarsThatMayNeedMainDeallocation ++ (NSValue * _Nonnull)_ivarsThatMayNeedMainDeallocation NS_RETURNS_RETAINED { static NSCache *ivarsCache; static dispatch_once_t onceToken; diff --git a/Source/ASMapNode.mm b/Source/ASMapNode.mm index 4697a2c05..e3e23df15 100644 --- a/Source/ASMapNode.mm +++ b/Source/ASMapNode.mm @@ -263,7 +263,7 @@ - (void)takeSnapshot }]; } -+ (UIImage *)defaultPinImageWithCenterOffset:(CGPoint *)centerOffset ++ (UIImage *)defaultPinImageWithCenterOffset:(CGPoint *)centerOffset NS_RETURNS_RETAINED { static MKAnnotationView *pin; static dispatch_once_t onceToken; diff --git a/Source/ASMultiplexImageNode.h b/Source/ASMultiplexImageNode.h index b3aa331e7..e4349d8cc 100644 --- a/Source/ASMultiplexImageNode.h +++ b/Source/ASMultiplexImageNode.h @@ -270,7 +270,7 @@ didFinishDownloadingImageWithIdentifier:(ASImageIdentifier)imageIdentifier + (NSURL *)URLWithAssetLocalIdentifier:(NSString *)assetLocalIdentifier targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode - options:(PHImageRequestOptions *)options AS_WARN_UNUSED_RESULT API_AVAILABLE(ios(8.0), tvos(10.0)); + options:(PHImageRequestOptions *)options NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT API_AVAILABLE(ios(8.0), tvos(10.0)); @end diff --git a/Source/ASMultiplexImageNode.mm b/Source/ASMultiplexImageNode.mm index 12a2647e1..9edf93b6a 100644 --- a/Source/ASMultiplexImageNode.mm +++ b/Source/ASMultiplexImageNode.mm @@ -894,7 +894,7 @@ - (void)_finishedLoadingImage:(UIImage *)image forIdentifier:(id)imageIdentifier @implementation NSURL (ASPhotosFrameworkURLs) -+ (NSURL *)URLWithAssetLocalIdentifier:(NSString *)assetLocalIdentifier targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(PHImageRequestOptions *)options ++ (NSURL *)URLWithAssetLocalIdentifier:(NSString *)assetLocalIdentifier targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(PHImageRequestOptions *)options NS_RETURNS_RETAINED { ASPhotosFrameworkImageRequest *request = [[ASPhotosFrameworkImageRequest alloc] initWithAssetIdentifier:assetLocalIdentifier]; request.options = options; diff --git a/Source/ASRunLoopQueue.h b/Source/ASRunLoopQueue.h index 02711910b..266cd71f3 100644 --- a/Source/ASRunLoopQueue.h +++ b/Source/ASRunLoopQueue.h @@ -68,6 +68,7 @@ AS_SUBCLASSING_RESTRICTED * Each node will only be called once per transaction commit to reflect interface change. */ @property (class, atomic, readonly) ASCATransactionQueue *sharedQueue; ++ (ASCATransactionQueue *)sharedQueue NS_RETURNS_RETAINED; - (void)enqueue:(id)object; @@ -83,6 +84,7 @@ AS_SUBCLASSING_RESTRICTED @interface ASDeallocQueue : NSObject @property (class, atomic, readonly) ASDeallocQueue *sharedDeallocationQueue; ++ (ASDeallocQueue *)sharedDeallocationQueue NS_RETURNS_RETAINED; - (void)test_drain; diff --git a/Source/ASRunLoopQueue.mm b/Source/ASRunLoopQueue.mm index 12265d1df..782618cc3 100644 --- a/Source/ASRunLoopQueue.mm +++ b/Source/ASRunLoopQueue.mm @@ -45,7 +45,7 @@ @implementation ASDeallocQueue { ASDN::RecursiveMutex _queueLock; } -+ (ASDeallocQueue *)sharedDeallocationQueue ++ (ASDeallocQueue *)sharedDeallocationQueue NS_RETURNS_RETAINED { static ASDeallocQueue *deallocQueue = nil; static dispatch_once_t onceToken; @@ -516,7 +516,7 @@ @implementation ASCATransactionQueue // and kASASCATransactionQueuePostOrder will apply interface change immediately. static int const kASASCATransactionQueuePostOrder = 3000000; -+ (ASCATransactionQueue *)sharedQueue ++ (ASCATransactionQueue *)sharedQueue NS_RETURNS_RETAINED { static dispatch_once_t onceToken; static ASCATransactionQueue *sharedQueue; diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index 39553c538..cced8e577 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -372,7 +372,7 @@ - (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer * NOTE: Be careful to copy `text` if needed. */ + (ASTextLayout *)compatibleLayoutWithContainer:(ASTextContainer *)container - text:(NSAttributedString *)text + text:(NSAttributedString *)text NS_RETURNS_RETAINED { // Allocate layoutCacheLock on the heap to prevent destruction at app exit (https://github.com/TextureGroup/Texture/issues/136) diff --git a/Source/Debug/AsyncDisplayKit+Debug.m b/Source/Debug/AsyncDisplayKit+Debug.m index 3225700e0..add247b14 100644 --- a/Source/Debug/AsyncDisplayKit+Debug.m +++ b/Source/Debug/AsyncDisplayKit+Debug.m @@ -213,7 +213,7 @@ - (void)drawEdgeIfClippedWithEdges:(UIRectEdge)rectEdge color:(UIColor *)color b @interface _ASRangeDebugOverlayView : UIView -+ (instancetype)sharedInstance; ++ (instancetype)sharedInstance NS_RETURNS_RETAINED; - (void)addRangeController:(ASRangeController *)rangeController; @@ -311,7 +311,7 @@ + (UIWindow *)keyWindow return [[NSClassFromString(@"UIApplication") sharedApplication] keyWindow]; } -+ (instancetype)sharedInstance ++ (_ASRangeDebugOverlayView *)sharedInstance NS_RETURNS_RETAINED { static _ASRangeDebugOverlayView *__rangeDebugOverlay = nil; @@ -752,7 +752,7 @@ - (ASImageNode *)createRangeNodeWithColor:(UIColor *)color return rangeBarImageNode; } -+ (NSAttributedString *)whiteAttributedStringFromString:(NSString *)string withSize:(CGFloat)size ++ (NSAttributedString *)whiteAttributedStringFromString:(NSString *)string withSize:(CGFloat)size NS_RETURNS_RETAINED { NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:size]}; diff --git a/Source/Details/ASBasicImageDownloader.h b/Source/Details/ASBasicImageDownloader.h index d1f8862d4..5d9a7b384 100644 --- a/Source/Details/ASBasicImageDownloader.h +++ b/Source/Details/ASBasicImageDownloader.h @@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN * @note It is strongly recommended you include PINRemoteImage and use @c ASPINRemoteImageDownloader instead. */ @property (class, readonly) ASBasicImageDownloader *sharedImageDownloader; ++ (ASBasicImageDownloader *)sharedImageDownloader NS_RETURNS_RETAINED; + (instancetype)new __attribute__((unavailable("+[ASBasicImageDownloader sharedImageDownloader] must be used."))); - (instancetype)init __attribute__((unavailable("+[ASBasicImageDownloader sharedImageDownloader] must be used."))); diff --git a/Source/Details/ASIntegerMap.h b/Source/Details/ASIntegerMap.h index 2b94a8fce..86e288942 100644 --- a/Source/Details/ASIntegerMap.h +++ b/Source/Details/ASIntegerMap.h @@ -29,7 +29,7 @@ AS_SUBCLASSING_RESTRICTED */ + (ASIntegerMap *)mapForUpdateWithOldCount:(NSInteger)oldCount deleted:(nullable NSIndexSet *)deleted - inserted:(nullable NSIndexSet *)inserted; + inserted:(nullable NSIndexSet *)inserted NS_RETURNS_RETAINED; /** * A singleton that maps each integer to itself. Its inverse is itself. @@ -37,6 +37,7 @@ AS_SUBCLASSING_RESTRICTED * Note: You cannot mutate this. */ @property (class, atomic, readonly) ASIntegerMap *identityMap; ++ (ASIntegerMap *)identityMap NS_RETURNS_RETAINED; /** * A singleton that returns NSNotFound for all keys. Its inverse is itself. @@ -44,6 +45,7 @@ AS_SUBCLASSING_RESTRICTED * Note: You cannot mutate this. */ @property (class, atomic, readonly) ASIntegerMap *emptyMap; ++ (ASIntegerMap *)emptyMap NS_RETURNS_RETAINED; /** * Retrieves the integer for a given key, or NSNotFound if the key is not found. diff --git a/Source/Details/ASIntegerMap.mm b/Source/Details/ASIntegerMap.mm index 4208b71a6..19f0bbe4a 100644 --- a/Source/Details/ASIntegerMap.mm +++ b/Source/Details/ASIntegerMap.mm @@ -31,7 +31,7 @@ @implementation ASIntegerMap { #pragma mark - Singleton -+ (ASIntegerMap *)identityMap ++ (ASIntegerMap *)identityMap NS_RETURNS_RETAINED { static ASIntegerMap *identityMap; static dispatch_once_t onceToken; @@ -43,7 +43,7 @@ + (ASIntegerMap *)identityMap return identityMap; } -+ (ASIntegerMap *)emptyMap ++ (ASIntegerMap *)emptyMap NS_RETURNS_RETAINED { static ASIntegerMap *emptyMap; static dispatch_once_t onceToken; @@ -55,7 +55,7 @@ + (ASIntegerMap *)emptyMap return emptyMap; } -+ (ASIntegerMap *)mapForUpdateWithOldCount:(NSInteger)oldCount deleted:(NSIndexSet *)deletions inserted:(NSIndexSet *)insertions ++ (ASIntegerMap *)mapForUpdateWithOldCount:(NSInteger)oldCount deleted:(NSIndexSet *)deletions inserted:(NSIndexSet *)insertions NS_RETURNS_RETAINED { if (oldCount == 0) { return ASIntegerMap.emptyMap; diff --git a/Source/Details/ASPINRemoteImageDownloader.h b/Source/Details/ASPINRemoteImageDownloader.h index abccd9f84..14b207dd9 100644 --- a/Source/Details/ASPINRemoteImageDownloader.h +++ b/Source/Details/ASPINRemoteImageDownloader.h @@ -35,6 +35,7 @@ NS_ASSUME_NONNULL_BEGIN * available. It uses PINRemoteImage's features to provide caching and progressive image downloads. */ @property (class, readonly) ASPINRemoteImageDownloader *sharedDownloader; ++ (ASPINRemoteImageDownloader *)sharedDownloader NS_RETURNS_RETAINED; /** diff --git a/Source/Details/ASPINRemoteImageDownloader.m b/Source/Details/ASPINRemoteImageDownloader.m index 3d050fd9e..9061026ec 100644 --- a/Source/Details/ASPINRemoteImageDownloader.m +++ b/Source/Details/ASPINRemoteImageDownloader.m @@ -114,7 +114,7 @@ @interface ASPINRemoteImageDownloader () @implementation ASPINRemoteImageDownloader -+ (ASPINRemoteImageDownloader *)sharedDownloader ++ (ASPINRemoteImageDownloader *)sharedDownloader NS_RETURNS_RETAINED { static dispatch_once_t onceToken = 0; diff --git a/Source/Details/ASPageTable.h b/Source/Details/ASPageTable.h index e295e0256..b512f0dc6 100644 --- a/Source/Details/ASPageTable.h +++ b/Source/Details/ASPageTable.h @@ -82,12 +82,12 @@ typedef ASPageTable *> AS /** * Creates a new page table with (NSMapTableStrongMemory | NSMapTableObjectPointerPersonality) for values. */ -+ (ASPageTable *)pageTableForStrongObjectPointers; ++ (ASPageTable *)pageTableForStrongObjectPointers NS_RETURNS_RETAINED; /** * Creates a new page table with (NSMapTableWeakMemory | NSMapTableObjectPointerPersonality) for values. */ -+ (ASPageTable *)pageTableForWeakObjectPointers; ++ (ASPageTable *)pageTableForWeakObjectPointers NS_RETURNS_RETAINED; /** * Builds a new page to layout attributes from the given layout attributes. @@ -98,7 +98,7 @@ typedef ASPageTable *> AS * * @param pageSize The size of each page. */ -+ (ASPageToLayoutAttributesTable *)pageTableWithLayoutAttributes:(id)layoutAttributesEnumerator contentSize:(CGSize)contentSize pageSize:(CGSize)pageSize; ++ (ASPageToLayoutAttributesTable *)pageTableWithLayoutAttributes:(id)layoutAttributesEnumerator contentSize:(CGSize)contentSize pageSize:(CGSize)pageSize NS_RETURNS_RETAINED; /** * Retrieves the object for a given page, or nil if the page is not found. diff --git a/Source/Details/ASPageTable.m b/Source/Details/ASPageTable.m index 5cbf758dd..6855b41b6 100644 --- a/Source/Details/ASPageTable.m +++ b/Source/Details/ASPageTable.m @@ -79,7 +79,7 @@ extern CGRect ASPageCoordinateGetPageRect(ASPageCoordinate pageCoordinate, CGSiz @implementation NSMapTable (ASPageTableMethods) -+ (instancetype)pageTableWithValuePointerFunctions:(NSPointerFunctions *)valueFuncs ++ (instancetype)pageTableWithValuePointerFunctions:(NSPointerFunctions *)valueFuncs NS_RETURNS_RETAINED { static NSPointerFunctions *pageCoordinatesFuncs; static dispatch_once_t onceToken; @@ -90,7 +90,7 @@ + (instancetype)pageTableWithValuePointerFunctions:(NSPointerFunctions *)valueFu return [[NSMapTable alloc] initWithKeyPointerFunctions:pageCoordinatesFuncs valuePointerFunctions:valueFuncs capacity:0]; } -+ (ASPageTable *)pageTableForStrongObjectPointers ++ (ASPageTable *)pageTableForStrongObjectPointers NS_RETURNS_RETAINED { static NSPointerFunctions *strongObjectPointerFuncs; static dispatch_once_t onceToken; @@ -100,7 +100,7 @@ + (ASPageTable *)pageTableForStrongObjectPointers return [self pageTableWithValuePointerFunctions:strongObjectPointerFuncs]; } -+ (ASPageTable *)pageTableForWeakObjectPointers ++ (ASPageTable *)pageTableForWeakObjectPointers NS_RETURNS_RETAINED { static NSPointerFunctions *weakObjectPointerFuncs; static dispatch_once_t onceToken; @@ -110,7 +110,7 @@ + (ASPageTable *)pageTableForWeakObjectPointers return [self pageTableWithValuePointerFunctions:weakObjectPointerFuncs]; } -+ (ASPageToLayoutAttributesTable *)pageTableWithLayoutAttributes:(id)layoutAttributesEnumerator contentSize:(CGSize)contentSize pageSize:(CGSize)pageSize ++ (ASPageToLayoutAttributesTable *)pageTableWithLayoutAttributes:(id)layoutAttributesEnumerator contentSize:(CGSize)contentSize pageSize:(CGSize)pageSize NS_RETURNS_RETAINED { ASPageToLayoutAttributesTable *result = [ASPageTable pageTableForStrongObjectPointers]; for (UICollectionViewLayoutAttributes *attrs in layoutAttributesEnumerator) { diff --git a/Source/Details/ASTraitCollection.h b/Source/Details/ASTraitCollection.h index 1932b487a..287bf5e43 100644 --- a/Source/Details/ASTraitCollection.h +++ b/Source/Details/ASTraitCollection.h @@ -194,11 +194,11 @@ AS_SUBCLASSING_RESTRICTED @property (nonatomic, assign, readonly) CGSize containerSize; + (ASTraitCollection *)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection - containerSize:(CGSize)windowSize; + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED; + (ASTraitCollection *)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection containerSize:(CGSize)windowSize - fallbackContentSizeCategory:(UIContentSizeCategory)fallbackContentSizeCategory; + fallbackContentSizeCategory:(UIContentSizeCategory)fallbackContentSizeCategory NS_RETURNS_RETAINED; #if TARGET_OS_TV + (ASTraitCollection *)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass)horizontalSizeClass @@ -210,7 +210,7 @@ AS_SUBCLASSING_RESTRICTED layoutDirection:(UITraitEnvironmentLayoutDirection)layoutDirection userInterfaceStyle:(UIUserInterfaceStyle)userInterfaceStyle preferredContentSizeCategory:(UIContentSizeCategory)preferredContentSizeCategory - containerSize:(CGSize)windowSize; + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED; #else + (ASTraitCollection *)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass)horizontalSizeClass verticalSizeClass:(UIUserInterfaceSizeClass)verticalSizeClass @@ -220,7 +220,7 @@ AS_SUBCLASSING_RESTRICTED forceTouchCapability:(UIForceTouchCapability)forceTouchCapability layoutDirection:(UITraitEnvironmentLayoutDirection)layoutDirection preferredContentSizeCategory:(UIContentSizeCategory)preferredContentSizeCategory - containerSize:(CGSize)windowSize; + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED; #endif - (BOOL)isEqualToTraitCollection:(ASTraitCollection *)traitCollection; @@ -232,7 +232,7 @@ AS_SUBCLASSING_RESTRICTED */ @interface ASTraitCollection (PrimitiveTraits) -+ (ASTraitCollection *)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits; ++ (ASTraitCollection *)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits NS_RETURNS_RETAINED; - (ASPrimitiveTraitCollection)primitiveTraitCollection; @@ -248,7 +248,7 @@ AS_SUBCLASSING_RESTRICTED verticalSizeClass:(UIUserInterfaceSizeClass)verticalSizeClass forceTouchCapability:(UIForceTouchCapability)forceTouchCapability containerSize:(CGSize)windowSize - ASDISPLAYNODE_DEPRECATED_MSG("Use full version of this method instead."); + NS_RETURNS_RETAINED ASDISPLAYNODE_DEPRECATED_MSG("Use full version of this method instead."); @end diff --git a/Source/Details/ASTraitCollection.m b/Source/Details/ASTraitCollection.m index 194fe8278..9b1902c9c 100644 --- a/Source/Details/ASTraitCollection.m +++ b/Source/Details/ASTraitCollection.m @@ -283,7 +283,7 @@ + (instancetype)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass layoutDirection:(UITraitEnvironmentLayoutDirection)layoutDirection userInterfaceStyle:(UIUserInterfaceStyle)userInterfaceStyle preferredContentSizeCategory:(UIContentSizeCategory _Nonnull)preferredContentSizeCategory - containerSize:(CGSize)windowSize + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED { return [[self alloc] initWithHorizontalSizeClass:horizontalSizeClass verticalSizeClass:verticalSizeClass @@ -332,7 +332,7 @@ + (instancetype)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass forceTouchCapability:(UIForceTouchCapability)forceTouchCapability layoutDirection:(UITraitEnvironmentLayoutDirection)layoutDirection preferredContentSizeCategory:(UIContentSizeCategory _Nonnull)preferredContentSizeCategory - containerSize:(CGSize)windowSize + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED { return [[self alloc] initWithHorizontalSizeClass:horizontalSizeClass verticalSizeClass:verticalSizeClass @@ -348,7 +348,7 @@ + (instancetype)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass #endif + (instancetype)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection - containerSize:(CGSize)windowSize + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED { return [self traitCollectionWithUITraitCollection:traitCollection containerSize:windowSize @@ -358,7 +358,7 @@ + (instancetype)traitCollectionWithUITraitCollection:(UITraitCollection *)traitC + (instancetype)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection containerSize:(CGSize)windowSize - fallbackContentSizeCategory:(UIContentSizeCategory _Nonnull)fallbackContentSizeCategory + fallbackContentSizeCategory:(UIContentSizeCategory _Nonnull)fallbackContentSizeCategory NS_RETURNS_RETAINED { UIDisplayGamut displayGamut; UITraitEnvironmentLayoutDirection layoutDirection; @@ -435,7 +435,7 @@ - (BOOL)isEqualToTraitCollection:(ASTraitCollection *)traitCollection @implementation ASTraitCollection (PrimitiveTraits) -+ (instancetype)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits ++ (instancetype)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits NS_RETURNS_RETAINED { #if TARGET_OS_TV return [self traitCollectionWithHorizontalSizeClass:traits.horizontalSizeClass @@ -514,7 +514,7 @@ + (ASTraitCollection *)traitCollectionWithDisplayScale:(CGFloat)displayScale horizontalSizeClass:(UIUserInterfaceSizeClass)horizontalSizeClass verticalSizeClass:(UIUserInterfaceSizeClass)verticalSizeClass forceTouchCapability:(UIForceTouchCapability)forceTouchCapability - containerSize:(CGSize)windowSize + containerSize:(CGSize)windowSize NS_RETURNS_RETAINED { #if TARGET_OS_TV return [self traitCollectionWithHorizontalSizeClass:horizontalSizeClass diff --git a/Source/Details/ASWeakProxy.h b/Source/Details/ASWeakProxy.h index 978204fbf..4a2490513 100644 --- a/Source/Details/ASWeakProxy.h +++ b/Source/Details/ASWeakProxy.h @@ -35,6 +35,6 @@ AS_SUBCLASSING_RESTRICTED * * @return an instance of ASWeakProxy */ -+ (instancetype)weakProxyWithTarget:(id)target; ++ (instancetype)weakProxyWithTarget:(id)target NS_RETURNS_RETAINED; @end diff --git a/Source/Details/ASWeakProxy.m b/Source/Details/ASWeakProxy.m index 9db965541..721191bc0 100644 --- a/Source/Details/ASWeakProxy.m +++ b/Source/Details/ASWeakProxy.m @@ -29,7 +29,7 @@ - (instancetype)initWithTarget:(id)target return self; } -+ (instancetype)weakProxyWithTarget:(id)target ++ (instancetype)weakProxyWithTarget:(id)target NS_RETURNS_RETAINED { return [[ASWeakProxy alloc] initWithTarget:target]; } diff --git a/Source/Layout/ASAbsoluteLayoutSpec.h b/Source/Layout/ASAbsoluteLayoutSpec.h index 0c250ec68..1080980c9 100644 --- a/Source/Layout/ASAbsoluteLayoutSpec.h +++ b/Source/Layout/ASAbsoluteLayoutSpec.h @@ -41,12 +41,12 @@ NS_ASSUME_NONNULL_BEGIN @param sizing How much space the spec will take up @param children Children to be positioned at fixed positions */ -+ (instancetype)absoluteLayoutSpecWithSizing:(ASAbsoluteLayoutSpecSizing)sizing children:(NSArray> *)children AS_WARN_UNUSED_RESULT; ++ (instancetype)absoluteLayoutSpecWithSizing:(ASAbsoluteLayoutSpecSizing)sizing children:(NSArray> *)children NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** @param children Children to be positioned at fixed positions */ -+ (instancetype)absoluteLayoutSpecWithChildren:(NSArray> *)children AS_WARN_UNUSED_RESULT; ++ (instancetype)absoluteLayoutSpecWithChildren:(NSArray> *)children NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASAbsoluteLayoutSpec.mm b/Source/Layout/ASAbsoluteLayoutSpec.mm index 96ab7a705..eede9ab76 100644 --- a/Source/Layout/ASAbsoluteLayoutSpec.mm +++ b/Source/Layout/ASAbsoluteLayoutSpec.mm @@ -28,12 +28,12 @@ @implementation ASAbsoluteLayoutSpec #pragma mark - Class -+ (instancetype)absoluteLayoutSpecWithChildren:(NSArray *)children ++ (instancetype)absoluteLayoutSpecWithChildren:(NSArray *)children NS_RETURNS_RETAINED { return [[self alloc] initWithChildren:children]; } -+ (instancetype)absoluteLayoutSpecWithSizing:(ASAbsoluteLayoutSpecSizing)sizing children:(NSArray> *)children ++ (instancetype)absoluteLayoutSpecWithSizing:(ASAbsoluteLayoutSpecSizing)sizing children:(NSArray> *)children NS_RETURNS_RETAINED { return [[self alloc] initWithSizing:sizing children:children]; } diff --git a/Source/Layout/ASAsciiArtBoxCreator.m b/Source/Layout/ASAsciiArtBoxCreator.m index 293127a64..e018978bd 100644 --- a/Source/Layout/ASAsciiArtBoxCreator.m +++ b/Source/Layout/ASAsciiArtBoxCreator.m @@ -35,7 +35,7 @@ @interface NSString(PIDebugBox) @implementation NSString(PIDebugBox) -+ (instancetype)debugbox_stringWithString:(NSString *)stringToRepeat repeatedCount:(NSUInteger)repeatCount ++ (instancetype)debugbox_stringWithString:(NSString *)stringToRepeat repeatedCount:(NSUInteger)repeatCount NS_RETURNS_RETAINED { NSMutableString *string = [[NSMutableString alloc] initWithCapacity:[stringToRepeat length] * repeatCount]; for (NSUInteger index = 0; index < repeatCount; index++) { diff --git a/Source/Layout/ASBackgroundLayoutSpec.h b/Source/Layout/ASBackgroundLayoutSpec.h index 882084d05..616d68fea 100644 --- a/Source/Layout/ASBackgroundLayoutSpec.h +++ b/Source/Layout/ASBackgroundLayoutSpec.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN * @param child A child that is laid out to determine the size of this spec. * @param background A layoutElement object that is laid out behind the child. */ -+ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background AS_WARN_UNUSED_RESULT; ++ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASBackgroundLayoutSpec.mm b/Source/Layout/ASBackgroundLayoutSpec.mm index e8c50901d..1cdf270a7 100644 --- a/Source/Layout/ASBackgroundLayoutSpec.mm +++ b/Source/Layout/ASBackgroundLayoutSpec.mm @@ -28,7 +28,7 @@ @implementation ASBackgroundLayoutSpec #pragma mark - Class -+ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background; ++ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background NS_RETURNS_RETAINED { return [[self alloc] initWithChild:child background:background]; } diff --git a/Source/Layout/ASCenterLayoutSpec.h b/Source/Layout/ASCenterLayoutSpec.h index f51a44b3a..825b375fb 100644 --- a/Source/Layout/ASCenterLayoutSpec.h +++ b/Source/Layout/ASCenterLayoutSpec.h @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN */ + (instancetype)centerLayoutSpecWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions - child:(id)child AS_WARN_UNUSED_RESULT; + child:(id)child NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASCenterLayoutSpec.mm b/Source/Layout/ASCenterLayoutSpec.mm index 0017a2a8e..230768faa 100644 --- a/Source/Layout/ASCenterLayoutSpec.mm +++ b/Source/Layout/ASCenterLayoutSpec.mm @@ -42,7 +42,7 @@ - (instancetype)initWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)cen + (instancetype)centerLayoutSpecWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions - child:(id)child + child:(id)child NS_RETURNS_RETAINED { return [[self alloc] initWithCenteringOptions:centeringOptions sizingOptions:sizingOptions child:child]; } diff --git a/Source/Layout/ASCornerLayoutSpec.h b/Source/Layout/ASCornerLayoutSpec.h index 23d09d017..cb5406611 100644 --- a/Source/Layout/ASCornerLayoutSpec.h +++ b/Source/Layout/ASCornerLayoutSpec.h @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN @param location The corner position option. @return An ASCornerLayoutSpec object with a given child and an layoutElement that act as corner. */ -+ (instancetype)cornerLayoutSpecWithChild:(id )child corner:(id )corner location:(ASCornerLayoutLocation)location AS_WARN_UNUSED_RESULT; ++ (instancetype)cornerLayoutSpecWithChild:(id )child corner:(id )corner location:(ASCornerLayoutLocation)location NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** A layoutElement object that is laid out to a corner on the child. diff --git a/Source/Layout/ASCornerLayoutSpec.mm b/Source/Layout/ASCornerLayoutSpec.mm index d1104089b..d2b88c70b 100644 --- a/Source/Layout/ASCornerLayoutSpec.mm +++ b/Source/Layout/ASCornerLayoutSpec.mm @@ -65,7 +65,7 @@ - (instancetype)initWithChild:(id )child corner:(id )child corner:(id )corner location:(ASCornerLayoutLocation)location ++ (instancetype)cornerLayoutSpecWithChild:(id )child corner:(id )corner location:(ASCornerLayoutLocation)location NS_RETURNS_RETAINED { return [[self alloc] initWithChild:child corner:corner location:location]; } diff --git a/Source/Layout/ASInsetLayoutSpec.h b/Source/Layout/ASInsetLayoutSpec.h index f12e54ff1..61b37b5e6 100644 --- a/Source/Layout/ASInsetLayoutSpec.h +++ b/Source/Layout/ASInsetLayoutSpec.h @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN @param insets The amount of space to inset on each side. @param child The wrapped child to inset. */ -+ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child AS_WARN_UNUSED_RESULT; ++ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASInsetLayoutSpec.mm b/Source/Layout/ASInsetLayoutSpec.mm index 5db1cf03e..23e0feace 100644 --- a/Source/Layout/ASInsetLayoutSpec.mm +++ b/Source/Layout/ASInsetLayoutSpec.mm @@ -59,7 +59,7 @@ - (instancetype)initWithInsets:(UIEdgeInsets)insets child:(id)c return self; } -+ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child ++ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child NS_RETURNS_RETAINED { return [[self alloc] initWithInsets:insets child:child]; } diff --git a/Source/Layout/ASLayout.h b/Source/Layout/ASLayout.h index fa1371985..81c88ddc0 100644 --- a/Source/Layout/ASLayout.h +++ b/Source/Layout/ASLayout.h @@ -108,7 +108,7 @@ ASDISPLAYNODE_EXTERN_C_END + (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size position:(CGPoint)position - sublayouts:(nullable NSArray *)sublayouts AS_WARN_UNUSED_RESULT; + sublayouts:(nullable NSArray *)sublayouts NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * Convenience initializer that has CGPointNull position. @@ -122,7 +122,7 @@ ASDISPLAYNODE_EXTERN_C_END */ + (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size - sublayouts:(nullable NSArray *)sublayouts AS_WARN_UNUSED_RESULT; + sublayouts:(nullable NSArray *)sublayouts NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * Convenience that has CGPointNull position and no sublayouts. @@ -133,11 +133,11 @@ ASDISPLAYNODE_EXTERN_C_END * @param size The size of this layout. */ + (instancetype)layoutWithLayoutElement:(id)layoutElement - size:(CGSize)size AS_WARN_UNUSED_RESULT; + size:(CGSize)size NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * Traverses the existing layout tree and generates a new tree that represents only ASDisplayNode layouts */ -- (ASLayout *)filteredNodeLayoutTree AS_WARN_UNUSED_RESULT; +- (ASLayout *)filteredNodeLayoutTree NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASLayout.mm b/Source/Layout/ASLayout.mm index f6fbe9127..1a1b419f4 100644 --- a/Source/Layout/ASLayout.mm +++ b/Source/Layout/ASLayout.mm @@ -166,7 +166,7 @@ - (instancetype)init + (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size position:(CGPoint)position - sublayouts:(nullable NSArray *)sublayouts + sublayouts:(nullable NSArray *)sublayouts NS_RETURNS_RETAINED { return [[self alloc] initWithLayoutElement:layoutElement size:size @@ -176,7 +176,7 @@ + (instancetype)layoutWithLayoutElement:(id)layoutElement + (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size - sublayouts:(nullable NSArray *)sublayouts + sublayouts:(nullable NSArray *)sublayouts NS_RETURNS_RETAINED { return [self layoutWithLayoutElement:layoutElement size:size @@ -184,7 +184,7 @@ + (instancetype)layoutWithLayoutElement:(id)layoutElement sublayouts:sublayouts]; } -+ (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size ++ (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size NS_RETURNS_RETAINED { return [self layoutWithLayoutElement:layoutElement size:size @@ -216,7 +216,7 @@ - (void)setRetainSublayoutLayoutElements:(BOOL)retainSublayoutLayoutElements #pragma mark - Layout Flattening -- (ASLayout *)filteredNodeLayoutTree +- (ASLayout *)filteredNodeLayoutTree NS_RETURNS_RETAINED { if (ASLayoutIsFlattened(self)) { // All flattened layouts must have this flag enabled diff --git a/Source/Layout/ASLayoutSpec.h b/Source/Layout/ASLayoutSpec.h index ac02bacd0..6a49792de 100644 --- a/Source/Layout/ASLayoutSpec.h +++ b/Source/Layout/ASLayoutSpec.h @@ -71,12 +71,12 @@ NS_ASSUME_NONNULL_BEGIN /* * Returns an ASWrapperLayoutSpec object with the given layoutElement as child. */ -+ (instancetype)wrapperWithLayoutElement:(id)layoutElement AS_WARN_UNUSED_RESULT; ++ (instancetype)wrapperWithLayoutElement:(id)layoutElement NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /* * Returns an ASWrapperLayoutSpec object with the given layoutElements as children. */ -+ (instancetype)wrapperWithLayoutElements:(NSArray> *)layoutElements AS_WARN_UNUSED_RESULT; ++ (instancetype)wrapperWithLayoutElements:(NSArray> *)layoutElements NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /* * Returns an ASWrapperLayoutSpec object initialized with the given layoutElement as child. diff --git a/Source/Layout/ASLayoutSpec.mm b/Source/Layout/ASLayoutSpec.mm index 76901d1ac..fa275d21d 100644 --- a/Source/Layout/ASLayoutSpec.mm +++ b/Source/Layout/ASLayoutSpec.mm @@ -265,7 +265,7 @@ - (NSString *)asciiArtName @implementation ASWrapperLayoutSpec -+ (instancetype)wrapperWithLayoutElement:(id)layoutElement ++ (instancetype)wrapperWithLayoutElement:(id)layoutElement NS_RETURNS_RETAINED { return [[self alloc] initWithLayoutElement:layoutElement]; } @@ -279,7 +279,7 @@ - (instancetype)initWithLayoutElement:(id)layoutElement return self; } -+ (instancetype)wrapperWithLayoutElements:(NSArray> *)layoutElements ++ (instancetype)wrapperWithLayoutElements:(NSArray> *)layoutElements NS_RETURNS_RETAINED { return [[self alloc] initWithLayoutElements:layoutElements]; } diff --git a/Source/Layout/ASOverlayLayoutSpec.h b/Source/Layout/ASOverlayLayoutSpec.h index 54324f4ed..086252075 100644 --- a/Source/Layout/ASOverlayLayoutSpec.h +++ b/Source/Layout/ASOverlayLayoutSpec.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN * @param child A child that is laid out to determine the size of this spec. * @param overlay A layoutElement object that is laid out over the child. */ -+ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay AS_WARN_UNUSED_RESULT; ++ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASOverlayLayoutSpec.mm b/Source/Layout/ASOverlayLayoutSpec.mm index 9ac5d1e56..77f8239da 100644 --- a/Source/Layout/ASOverlayLayoutSpec.mm +++ b/Source/Layout/ASOverlayLayoutSpec.mm @@ -26,7 +26,7 @@ @implementation ASOverlayLayoutSpec #pragma mark - Class -+ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay ++ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay NS_RETURNS_RETAINED { return [[self alloc] initWithChild:child overlay:overlay]; } diff --git a/Source/Layout/ASRatioLayoutSpec.h b/Source/Layout/ASRatioLayoutSpec.h index f5338d4da..b6f9987b5 100644 --- a/Source/Layout/ASRatioLayoutSpec.h +++ b/Source/Layout/ASRatioLayoutSpec.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) CGFloat ratio; -+ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child AS_WARN_UNUSED_RESULT; ++ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASRatioLayoutSpec.mm b/Source/Layout/ASRatioLayoutSpec.mm index 294d11064..aec3a9c8f 100644 --- a/Source/Layout/ASRatioLayoutSpec.mm +++ b/Source/Layout/ASRatioLayoutSpec.mm @@ -35,7 +35,7 @@ @implementation ASRatioLayoutSpec #pragma mark - Lifecycle -+ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child ++ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child NS_RETURNS_RETAINED { return [[self alloc] initWithRatio:ratio child:child]; } diff --git a/Source/Layout/ASRelativeLayoutSpec.h b/Source/Layout/ASRelativeLayoutSpec.h index 27860b00e..cd3f14c9f 100644 --- a/Source/Layout/ASRelativeLayoutSpec.h +++ b/Source/Layout/ASRelativeLayoutSpec.h @@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption - child:(id)child AS_WARN_UNUSED_RESULT; + child:(id)child NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /*! * @discussion convenience initializer for a ASRelativeLayoutSpec diff --git a/Source/Layout/ASRelativeLayoutSpec.mm b/Source/Layout/ASRelativeLayoutSpec.mm index ea5f37df5..b14795d27 100644 --- a/Source/Layout/ASRelativeLayoutSpec.mm +++ b/Source/Layout/ASRelativeLayoutSpec.mm @@ -36,7 +36,7 @@ - (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizon return self; } -+ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child ++ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child NS_RETURNS_RETAINED { return [[self alloc] initWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOption child:child]; } diff --git a/Source/Layout/ASStackLayoutSpec.h b/Source/Layout/ASStackLayoutSpec.h index b4a27697e..44721f53d 100644 --- a/Source/Layout/ASStackLayoutSpec.h +++ b/Source/Layout/ASStackLayoutSpec.h @@ -88,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems - children:(NSArray> *)children AS_WARN_UNUSED_RESULT; + children:(NSArray> *)children NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** @param direction The direction of the stack view (horizontal or vertical) @@ -105,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN alignItems:(ASStackLayoutAlignItems)alignItems flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent - children:(NSArray> *)children AS_WARN_UNUSED_RESULT; + children:(NSArray> *)children NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** @param direction The direction of the stack view (horizontal or vertical) @@ -124,17 +124,17 @@ NS_ASSUME_NONNULL_BEGIN flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent lineSpacing:(CGFloat)lineSpacing - children:(NSArray> *)children AS_WARN_UNUSED_RESULT; + children:(NSArray> *)children NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * @return A stack layout spec with direction of ASStackLayoutDirectionVertical **/ -+ (instancetype)verticalStackLayoutSpec AS_WARN_UNUSED_RESULT; ++ (instancetype)verticalStackLayoutSpec NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * @return A stack layout spec with direction of ASStackLayoutDirectionHorizontal **/ -+ (instancetype)horizontalStackLayoutSpec AS_WARN_UNUSED_RESULT; ++ (instancetype)horizontalStackLayoutSpec NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/Layout/ASStackLayoutSpec.mm b/Source/Layout/ASStackLayoutSpec.mm index fc89d6f97..756912d80 100644 --- a/Source/Layout/ASStackLayoutSpec.mm +++ b/Source/Layout/ASStackLayoutSpec.mm @@ -36,29 +36,29 @@ - (instancetype)init return [self initWithDirection:ASStackLayoutDirectionHorizontal spacing:0.0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch flexWrap:ASStackLayoutFlexWrapNoWrap alignContent:ASStackLayoutAlignContentStart lineSpacing:0.0 children:nil]; } -+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children ++ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children NS_RETURNS_RETAINED { return [[self alloc] initWithDirection:direction spacing:spacing justifyContent:justifyContent alignItems:alignItems flexWrap:ASStackLayoutFlexWrapNoWrap alignContent:ASStackLayoutAlignContentStart lineSpacing: 0.0 children:children]; } -+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent children:(NSArray> *)children ++ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent children:(NSArray> *)children NS_RETURNS_RETAINED { return [[self alloc] initWithDirection:direction spacing:spacing justifyContent:justifyContent alignItems:alignItems flexWrap:flexWrap alignContent:alignContent lineSpacing:0.0 children:children]; } -+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent lineSpacing:(CGFloat)lineSpacing children:(NSArray> *)children ++ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems flexWrap:(ASStackLayoutFlexWrap)flexWrap alignContent:(ASStackLayoutAlignContent)alignContent lineSpacing:(CGFloat)lineSpacing children:(NSArray> *)children NS_RETURNS_RETAINED { return [[self alloc] initWithDirection:direction spacing:spacing justifyContent:justifyContent alignItems:alignItems flexWrap:flexWrap alignContent:alignContent lineSpacing:lineSpacing children:children]; } -+ (instancetype)verticalStackLayoutSpec ++ (instancetype)verticalStackLayoutSpec NS_RETURNS_RETAINED { ASStackLayoutSpec *stackLayoutSpec = [[self alloc] init]; stackLayoutSpec.direction = ASStackLayoutDirectionVertical; return stackLayoutSpec; } -+ (instancetype)horizontalStackLayoutSpec ++ (instancetype)horizontalStackLayoutSpec NS_RETURNS_RETAINED { ASStackLayoutSpec *stackLayoutSpec = [[self alloc] init]; stackLayoutSpec.direction = ASStackLayoutDirectionHorizontal; diff --git a/Source/Private/ASRectMap.h b/Source/Private/ASRectMap.h index fd756b333..e4b05d7cb 100644 --- a/Source/Private/ASRectMap.h +++ b/Source/Private/ASRectMap.h @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Creates a new rect map. The keys are never retained. */ -+ (ASRectMap *)rectMapForWeakObjectPointers; ++ (ASRectMap *)rectMapForWeakObjectPointers NS_RETURNS_RETAINED; /** * Retrieves the rect for a given key, or CGRectNull if the key is not found. diff --git a/Source/Private/ASRectMap.mm b/Source/Private/ASRectMap.mm index cb7681080..2e4398c32 100644 --- a/Source/Private/ASRectMap.mm +++ b/Source/Private/ASRectMap.mm @@ -19,7 +19,7 @@ @implementation ASRectMap { std::unordered_map _map; } -+ (ASRectMap *)rectMapForWeakObjectPointers ++ (ASRectMap *)rectMapForWeakObjectPointers NS_RETURNS_RETAINED { return [[self alloc] init]; } diff --git a/Source/Private/TextExperiment/Component/ASTextInput.h b/Source/Private/TextExperiment/Component/ASTextInput.h index 6b2aa79bb..061eef310 100755 --- a/Source/Private/TextExperiment/Component/ASTextInput.h +++ b/Source/Private/TextExperiment/Component/ASTextInput.h @@ -1,12 +1,18 @@ // // ASTextInput.h -// Modified from YYText +// Texture // -// Created by ibireme on 15/4/17. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -36,8 +42,8 @@ typedef NS_ENUM(NSInteger, ASTextAffinity) { @property (nonatomic, readonly) NSInteger offset; @property (nonatomic, readonly) ASTextAffinity affinity; -+ (instancetype)positionWithOffset:(NSInteger)offset; -+ (instancetype)positionWithOffset:(NSInteger)offset affinity:(ASTextAffinity) affinity; ++ (instancetype)positionWithOffset:(NSInteger)offset NS_RETURNS_RETAINED; ++ (instancetype)positionWithOffset:(NSInteger)offset affinity:(ASTextAffinity) affinity NS_RETURNS_RETAINED; - (NSComparisonResult)compare:(id)otherPosition; @@ -57,10 +63,10 @@ typedef NS_ENUM(NSInteger, ASTextAffinity) { @property (nonatomic, readonly) ASTextPosition *end; @property (nonatomic, readonly, getter=isEmpty) BOOL empty; -+ (instancetype)rangeWithRange:(NSRange)range; -+ (instancetype)rangeWithRange:(NSRange)range affinity:(ASTextAffinity) affinity; -+ (instancetype)rangeWithStart:(ASTextPosition *)start end:(ASTextPosition *)end; -+ (instancetype)defaultRange; ///< <{0,0} Forward> ++ (instancetype)rangeWithRange:(NSRange)range NS_RETURNS_RETAINED; ++ (instancetype)rangeWithRange:(NSRange)range affinity:(ASTextAffinity) affinity NS_RETURNS_RETAINED; ++ (instancetype)rangeWithStart:(ASTextPosition *)start end:(ASTextPosition *)end NS_RETURNS_RETAINED; ++ (instancetype)defaultRange NS_RETURNS_RETAINED; ///< <{0,0} Forward> - (NSRange)asRange; diff --git a/Source/Private/TextExperiment/Component/ASTextInput.m b/Source/Private/TextExperiment/Component/ASTextInput.m index fa1c53b22..a56426b16 100755 --- a/Source/Private/TextExperiment/Component/ASTextInput.m +++ b/Source/Private/TextExperiment/Component/ASTextInput.m @@ -1,12 +1,18 @@ // // ASTextInput.m -// Modified from YYText +// Texture // -// Created by ibireme on 15/4/17. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -15,11 +21,11 @@ @implementation ASTextPosition -+ (instancetype)positionWithOffset:(NSInteger)offset { ++ (instancetype)positionWithOffset:(NSInteger)offset NS_RETURNS_RETAINED { return [self positionWithOffset:offset affinity:ASTextAffinityForward]; } -+ (instancetype)positionWithOffset:(NSInteger)offset affinity:(ASTextAffinity)affinity { ++ (instancetype)positionWithOffset:(NSInteger)offset affinity:(ASTextAffinity)affinity NS_RETURNS_RETAINED { ASTextPosition *p = [self new]; p->_offset = offset; p->_affinity = affinity; @@ -85,17 +91,17 @@ - (NSRange)asRange { return NSMakeRange(_start.offset, _end.offset - _start.offset); } -+ (instancetype)rangeWithRange:(NSRange)range { ++ (instancetype)rangeWithRange:(NSRange)range NS_RETURNS_RETAINED { return [self rangeWithRange:range affinity:ASTextAffinityForward]; } -+ (instancetype)rangeWithRange:(NSRange)range affinity:(ASTextAffinity)affinity { ++ (instancetype)rangeWithRange:(NSRange)range affinity:(ASTextAffinity)affinity NS_RETURNS_RETAINED { ASTextPosition *start = [ASTextPosition positionWithOffset:range.location affinity:affinity]; ASTextPosition *end = [ASTextPosition positionWithOffset:range.location + range.length affinity:affinity]; return [self rangeWithStart:start end:end]; } -+ (instancetype)rangeWithStart:(ASTextPosition *)start end:(ASTextPosition *)end { ++ (instancetype)rangeWithStart:(ASTextPosition *)start end:(ASTextPosition *)end NS_RETURNS_RETAINED { if (!start || !end) return nil; if ([start compare:end] == NSOrderedDescending) { ASTEXT_SWAP(start, end); @@ -106,7 +112,7 @@ + (instancetype)rangeWithStart:(ASTextPosition *)start end:(ASTextPosition *)end return range; } -+ (instancetype)defaultRange { ++ (instancetype)defaultRange NS_RETURNS_RETAINED { return [self new]; } diff --git a/Source/Private/TextExperiment/Component/ASTextLayout.h b/Source/Private/TextExperiment/Component/ASTextLayout.h index e2cd9873e..5de6f057c 100755 --- a/Source/Private/TextExperiment/Component/ASTextLayout.h +++ b/Source/Private/TextExperiment/Component/ASTextLayout.h @@ -1,12 +1,18 @@ // // ASTextLayout.h -// Modified from YYText +// Texture // -// Created by ibireme on 15/3/3. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -53,13 +59,13 @@ extern const CGSize ASTextContainerMaxSize; @interface ASTextContainer : NSObject /// Creates a container with the specified size. @param size The size. -+ (instancetype)containerWithSize:(CGSize)size; ++ (instancetype)containerWithSize:(CGSize)size NS_RETURNS_RETAINED; /// Creates a container with the specified size and insets. @param size The size. @param insets The text insets. -+ (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets; ++ (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets NS_RETURNS_RETAINED; /// Creates a container with the specified path. @param path The path. -+ (instancetype)containerWithPath:(nullable UIBezierPath *)path; ++ (instancetype)containerWithPath:(nullable UIBezierPath *)path NS_RETURNS_RETAINED; /// The constrained size. (if the size is larger than ASTextContainerMaxSize, it will be clipped) @property CGSize size; diff --git a/Source/Private/TextExperiment/Component/ASTextLayout.m b/Source/Private/TextExperiment/Component/ASTextLayout.m index fa61946c5..3707e3d94 100755 --- a/Source/Private/TextExperiment/Component/ASTextLayout.m +++ b/Source/Private/TextExperiment/Component/ASTextLayout.m @@ -1,12 +1,18 @@ // // ASTextLayout.m -// Modified from YYText +// Texture // -// Created by ibireme on 15/3/3. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -99,18 +105,18 @@ @implementation ASTextContainer { id _linePositionModifier; } -+ (instancetype)containerWithSize:(CGSize)size { ++ (instancetype)containerWithSize:(CGSize)size NS_RETURNS_RETAINED { return [self containerWithSize:size insets:UIEdgeInsetsZero]; } -+ (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets { ++ (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets NS_RETURNS_RETAINED { ASTextContainer *one = [self new]; one.size = ASTextClipCGSize(size); one.insets = insets; return one; } -+ (instancetype)containerWithPath:(UIBezierPath *)path { ++ (instancetype)containerWithPath:(UIBezierPath *)path NS_RETURNS_RETAINED { ASTextContainer *one = [self new]; one.path = path; return one; diff --git a/Source/Private/TextExperiment/Component/ASTextLine.h b/Source/Private/TextExperiment/Component/ASTextLine.h index 10d2685db..2befb4581 100755 --- a/Source/Private/TextExperiment/Component/ASTextLine.h +++ b/Source/Private/TextExperiment/Component/ASTextLine.h @@ -1,12 +1,18 @@ // // ASTextLine.h -// Modified from YYText +// Texture // -// Created by ibireme on 15/3/10. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -22,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface ASTextLine : NSObject -+ (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical; ++ (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical NS_RETURNS_RETAINED; @property (nonatomic) NSUInteger index; ///< line index @property (nonatomic) NSUInteger row; ///< line row @@ -73,7 +79,7 @@ typedef NS_ENUM(NSUInteger, ASTextRunGlyphDrawMode) { @interface ASTextRunGlyphRange : NSObject @property (nonatomic) NSRange glyphRangeInRun; @property (nonatomic) ASTextRunGlyphDrawMode drawMode; -+ (instancetype)rangeWithRange:(NSRange)range drawMode:(ASTextRunGlyphDrawMode)mode; ++ (instancetype)rangeWithRange:(NSRange)range drawMode:(ASTextRunGlyphDrawMode)mode NS_RETURNS_RETAINED; @end NS_ASSUME_NONNULL_END diff --git a/Source/Private/TextExperiment/Component/ASTextLine.m b/Source/Private/TextExperiment/Component/ASTextLine.m index 14d9f7fd2..a0b8a173d 100755 --- a/Source/Private/TextExperiment/Component/ASTextLine.m +++ b/Source/Private/TextExperiment/Component/ASTextLine.m @@ -1,12 +1,18 @@ // -// ASYTextLine.m -// Modified from YYText +// ASTextLine.m +// Texture // -// Created by ibireme on 15/3/3. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -16,7 +22,7 @@ @implementation ASTextLine { CGFloat _firstGlyphPos; // first glyph position for baseline, typically 0. } -+ (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical { ++ (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical NS_RETURNS_RETAINED { if (!CTLine) return nil; ASTextLine *line = [self new]; line->_position = position; @@ -157,7 +163,7 @@ - (NSString *)description { @implementation ASTextRunGlyphRange -+ (instancetype)rangeWithRange:(NSRange)range drawMode:(ASTextRunGlyphDrawMode)mode { ++ (instancetype)rangeWithRange:(NSRange)range drawMode:(ASTextRunGlyphDrawMode)mode NS_RETURNS_RETAINED { ASTextRunGlyphRange *one = [self new]; one.glyphRangeInRun = range; one.drawMode = mode; diff --git a/Source/Private/TextExperiment/String/ASTextAttribute.h b/Source/Private/TextExperiment/String/ASTextAttribute.h index 80cdf64ec..87716e9ce 100755 --- a/Source/Private/TextExperiment/String/ASTextAttribute.h +++ b/Source/Private/TextExperiment/String/ASTextAttribute.h @@ -1,12 +1,18 @@ // // ASTextAttribute.h -// Modified from YYText +// Texture // -// Created by ibireme on 14/10/26. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import @@ -173,7 +179,7 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR Example: If :) is replace by a custom emoji (such as😊), the backed string can be set to @":)". */ @interface ASTextBackedString : NSObject -+ (instancetype)stringWithString:(nullable NSString *)string; ++ (instancetype)stringWithString:(nullable NSString *)string NS_RETURNS_RETAINED; @property (nullable, nonatomic, copy) NSString *string; ///< backed string @end @@ -188,7 +194,7 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR selection and edit. */ @interface ASTextBinding : NSObject -+ (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm; ++ (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm NS_RETURNS_RETAINED; @property (nonatomic) BOOL deleteConfirm; ///< confirm the range when delete in ASTextView @end @@ -201,7 +207,7 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR It's similar to `NSShadow`, but offers more options. */ @interface ASTextShadow : NSObject -+ (instancetype)shadowWithColor:(nullable UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius; ++ (instancetype)shadowWithColor:(nullable UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius NS_RETURNS_RETAINED; @property (nullable, nonatomic, strong) UIColor *color; ///< shadow color @property (nonatomic) CGSize offset; ///< shadow offset @@ -209,7 +215,7 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR @property (nonatomic) CGBlendMode blendMode; ///< shadow blend mode @property (nullable, nonatomic, strong) ASTextShadow *subShadow; ///< a sub shadow which will be added above the parent shadow -+ (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow; ///< convert NSShadow to ASTextShadow ++ (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow NS_RETURNS_RETAINED; ///< convert NSShadow to ASTextShadow - (NSShadow *)nsShadow; ///< convert ASTextShadow to NSShadow @end @@ -223,8 +229,8 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR when it's used as strikethrough, the line is drawn above text glyphs. */ @interface ASTextDecoration : NSObject -+ (instancetype)decorationWithStyle:(ASTextLineStyle)style; -+ (instancetype)decorationWithStyle:(ASTextLineStyle)style width:(nullable NSNumber *)width color:(nullable UIColor *)color; ++ (instancetype)decorationWithStyle:(ASTextLineStyle)style NS_RETURNS_RETAINED; ++ (instancetype)decorationWithStyle:(ASTextLineStyle)style width:(nullable NSNumber *)width color:(nullable UIColor *)color NS_RETURNS_RETAINED; @property (nonatomic) ASTextLineStyle style; ///< line style @property (nullable, nonatomic, strong) NSNumber *width; ///< line width (nil means automatic width) @property (nullable, nonatomic, strong) UIColor *color; ///< line color (nil means automatic color) @@ -246,8 +252,8 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR ╰──────╯ */ @interface ASTextBorder : NSObject -+ (instancetype)borderWithLineStyle:(ASTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(nullable UIColor *)color; -+ (instancetype)borderWithFillColor:(nullable UIColor *)color cornerRadius:(CGFloat)cornerRadius; ++ (instancetype)borderWithLineStyle:(ASTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(nullable UIColor *)color NS_RETURNS_RETAINED; ++ (instancetype)borderWithFillColor:(nullable UIColor *)color cornerRadius:(CGFloat)cornerRadius NS_RETURNS_RETAINED; @property (nonatomic) ASTextLineStyle lineStyle; ///< border line style @property (nonatomic) CGFloat strokeWidth; ///< border line width @property (nullable, nonatomic, strong) UIColor *strokeColor; ///< border line color @@ -270,7 +276,7 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR then it will be added to the text container's view or layer. */ @interface ASTextAttachment : NSObject -+ (instancetype)attachmentWithContent:(nullable id)content; ++ (instancetype)attachmentWithContent:(nullable id)content NS_RETURNS_RETAINED; @property (nullable, nonatomic, strong) id content; ///< Supported type: UIImage, UIView, CALayer @property (nonatomic) UIViewContentMode contentMode; ///< Content display mode. @property (nonatomic) UIEdgeInsets contentInsets; ///< The insets when drawing content. @@ -303,14 +309,14 @@ typedef void(^ASTextAction)(UIView *containerView, NSAttributedString *text, NSR @param attributes The attributes which will replace original attributes when highlight, If the value is NSNull, it will removed when highlight. */ -+ (instancetype)highlightWithAttributes:(nullable NSDictionary *)attributes; ++ (instancetype)highlightWithAttributes:(nullable NSDictionary *)attributes NS_RETURNS_RETAINED; /** Convenience methods to create a default highlight with the specifeid background color. @param color The background border color. */ -+ (instancetype)highlightWithBackgroundColor:(nullable UIColor *)color; ++ (instancetype)highlightWithBackgroundColor:(nullable UIColor *)color NS_RETURNS_RETAINED; // Convenience methods below to set the `attributes`. - (void)setFont:(nullable UIFont *)font; diff --git a/Source/Private/TextExperiment/String/ASTextAttribute.m b/Source/Private/TextExperiment/String/ASTextAttribute.m index 76ff0df38..f5bb64224 100755 --- a/Source/Private/TextExperiment/String/ASTextAttribute.m +++ b/Source/Private/TextExperiment/String/ASTextAttribute.m @@ -1,12 +1,18 @@ // // ASTextAttribute.m -// Modified from YYText +// Texture // -// Created by ibireme on 14/10/26. -// Copyright (c) 2015 ibireme. +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. // -// This source code is licensed under the MIT-style license found in the -// LICENSE file in the root directory of this source tree. +// Modifications to this file made after 4/13/2017 are: Copyright (c) through the present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 // #import "ASTextAttribute.h" @@ -109,7 +115,7 @@ ASTextAttributeType ASTextAttributeGetType(NSString *name){ @implementation ASTextBackedString -+ (instancetype)stringWithString:(NSString *)string { ++ (instancetype)stringWithString:(NSString *)string NS_RETURNS_RETAINED { ASTextBackedString *one = [self new]; one.string = string; return one; @@ -136,7 +142,7 @@ - (id)copyWithZone:(NSZone *)zone { @implementation ASTextBinding -+ (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm { ++ (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm NS_RETURNS_RETAINED { ASTextBinding *one = [self new]; one.deleteConfirm = deleteConfirm; return one; @@ -163,7 +169,7 @@ - (id)copyWithZone:(NSZone *)zone { @implementation ASTextShadow -+ (instancetype)shadowWithColor:(UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius { ++ (instancetype)shadowWithColor:(UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius NS_RETURNS_RETAINED { ASTextShadow *one = [self new]; one.color = color; one.offset = offset; @@ -171,7 +177,7 @@ + (instancetype)shadowWithColor:(UIColor *)color offset:(CGSize)offset radius:(C return one; } -+ (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow { ++ (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow NS_RETURNS_RETAINED { if (!nsShadow) return nil; ASTextShadow *shadow = [self new]; shadow.offset = nsShadow.shadowOffset; @@ -232,12 +238,12 @@ - (instancetype)init { return self; } -+ (instancetype)decorationWithStyle:(ASTextLineStyle)style { ++ (instancetype)decorationWithStyle:(ASTextLineStyle)style NS_RETURNS_RETAINED { ASTextDecoration *one = [self new]; one.style = style; return one; } -+ (instancetype)decorationWithStyle:(ASTextLineStyle)style width:(NSNumber *)width color:(UIColor *)color { ++ (instancetype)decorationWithStyle:(ASTextLineStyle)style width:(NSNumber *)width color:(UIColor *)color NS_RETURNS_RETAINED { ASTextDecoration *one = [self new]; one.style = style; one.width = width; @@ -272,7 +278,7 @@ - (id)copyWithZone:(NSZone *)zone { @implementation ASTextBorder -+ (instancetype)borderWithLineStyle:(ASTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(UIColor *)color { ++ (instancetype)borderWithLineStyle:(ASTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(UIColor *)color NS_RETURNS_RETAINED { ASTextBorder *one = [self new]; one.lineStyle = lineStyle; one.strokeWidth = width; @@ -280,7 +286,7 @@ + (instancetype)borderWithLineStyle:(ASTextLineStyle)lineStyle lineWidth:(CGFloa return one; } -+ (instancetype)borderWithFillColor:(UIColor *)color cornerRadius:(CGFloat)cornerRadius { ++ (instancetype)borderWithFillColor:(UIColor *)color cornerRadius:(CGFloat)cornerRadius NS_RETURNS_RETAINED { ASTextBorder *one = [self new]; one.fillColor = color; one.cornerRadius = cornerRadius; @@ -336,7 +342,7 @@ - (id)copyWithZone:(NSZone *)zone { @implementation ASTextAttachment -+ (instancetype)attachmentWithContent:(id)content { ++ (instancetype)attachmentWithContent:(id)content NS_RETURNS_RETAINED { ASTextAttachment *one = [self new]; one.content = content; return one; @@ -373,13 +379,13 @@ - (id)copyWithZone:(NSZone *)zone { @implementation ASTextHighlight -+ (instancetype)highlightWithAttributes:(NSDictionary *)attributes { ++ (instancetype)highlightWithAttributes:(NSDictionary *)attributes NS_RETURNS_RETAINED { ASTextHighlight *one = [self new]; one.attributes = attributes; return one; } -+ (instancetype)highlightWithBackgroundColor:(UIColor *)color { ++ (instancetype)highlightWithBackgroundColor:(UIColor *)color NS_RETURNS_RETAINED { ASTextBorder *highlightBorder = [ASTextBorder new]; highlightBorder.insets = UIEdgeInsetsMake(-2, -1, -2, -1); highlightBorder.cornerRadius = 3; diff --git a/Source/TextKit/ASTextKitComponents.h b/Source/TextKit/ASTextKitComponents.h index 20acc2c47..c516fe69e 100644 --- a/Source/TextKit/ASTextKitComponents.h +++ b/Source/TextKit/ASTextKitComponents.h @@ -37,7 +37,7 @@ AS_SUBCLASSING_RESTRICTED @discussion The returned components will be hooked up together, so they are ready for use as a system upon return. */ + (instancetype)componentsWithAttributedSeedString:(nullable NSAttributedString *)attributedSeedString - textContainerSize:(CGSize)textContainerSize; + textContainerSize:(CGSize)textContainerSize NS_RETURNS_RETAINED; /** @abstract Creates the stack of TextKit components. @@ -49,7 +49,7 @@ AS_SUBCLASSING_RESTRICTED */ + (instancetype)componentsWithTextStorage:(NSTextStorage *)textStorage textContainerSize:(CGSize)textContainerSize - layoutManager:(NSLayoutManager *)layoutManager; + layoutManager:(NSLayoutManager *)layoutManager NS_RETURNS_RETAINED; /** @abstract Returns the bounding size for the text view's text. diff --git a/Source/TextKit/ASTextKitComponents.mm b/Source/TextKit/ASTextKitComponents.mm index 7e4a7ae68..dbb611b78 100644 --- a/Source/TextKit/ASTextKitComponents.mm +++ b/Source/TextKit/ASTextKitComponents.mm @@ -65,7 +65,7 @@ @implementation ASTextKitComponents #pragma mark - Class + (instancetype)componentsWithAttributedSeedString:(NSAttributedString *)attributedSeedString - textContainerSize:(CGSize)textContainerSize + textContainerSize:(CGSize)textContainerSize NS_RETURNS_RETAINED { NSTextStorage *textStorage = attributedSeedString ? [[NSTextStorage alloc] initWithAttributedString:attributedSeedString] : [[NSTextStorage alloc] init]; @@ -76,7 +76,7 @@ + (instancetype)componentsWithAttributedSeedString:(NSAttributedString *)attribu + (instancetype)componentsWithTextStorage:(NSTextStorage *)textStorage textContainerSize:(CGSize)textContainerSize - layoutManager:(NSLayoutManager *)layoutManager + layoutManager:(NSLayoutManager *)layoutManager NS_RETURNS_RETAINED { ASTextKitComponents *components = [[self alloc] init]; diff --git a/Source/TextKit/ASTextKitCoreTextAdditions.h b/Source/TextKit/ASTextKitCoreTextAdditions.h index 94108961c..211250e8c 100644 --- a/Source/TextKit/ASTextKitCoreTextAdditions.h +++ b/Source/TextKit/ASTextKitCoreTextAdditions.h @@ -88,7 +88,7 @@ ASDISPLAYNODE_EXTERN_C_END @result An NSParagraphStyle initialized with as many of the paragraph specifiers from `coreTextParagraphStyle` as possible. */ -+ (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle; ++ (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle NS_RETURNS_RETAINED; @end diff --git a/Source/TextKit/ASTextKitCoreTextAdditions.m b/Source/TextKit/ASTextKitCoreTextAdditions.m index 7f48aff71..272cacd3d 100644 --- a/Source/TextKit/ASTextKitCoreTextAdditions.m +++ b/Source/TextKit/ASTextKitCoreTextAdditions.m @@ -172,7 +172,7 @@ BOOL ASAttributeWithNameIsUnsupportedCoreTextAttribute(NSString *attributeName) #pragma mark - @implementation NSParagraphStyle (ASTextKitCoreTextAdditions) -+ (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle; ++ (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle NS_RETURNS_RETAINED { NSMutableParagraphStyle *newParagraphStyle = [[NSMutableParagraphStyle alloc] init]; diff --git a/Source/UIImage+ASConvenience.h b/Source/UIImage+ASConvenience.h index e9612c8b7..915571b7c 100644 --- a/Source/UIImage+ASConvenience.h +++ b/Source/UIImage+ASConvenience.h @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN * @param imageName The name of the image to load * @return The loaded image or nil */ -+ (UIImage *)as_imageNamed:(NSString *)imageName; ++ (UIImage *)as_imageNamed:(NSString *)imageName NS_RETURNS_RETAINED; /** * A version of imageNamed that caches results because loading an image is expensive. @@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN * @param traitCollection The traits associated with the intended environment for the image. * @return The loaded image or nil */ -+ (UIImage *)as_imageNamed:(NSString *)imageName compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection; ++ (UIImage *)as_imageNamed:(NSString *)imageName compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection NS_RETURNS_RETAINED; @end @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN */ + (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius cornerColor:(nullable UIColor *)cornerColor - fillColor:(UIColor *)fillColor AS_WARN_UNUSED_RESULT; + fillColor:(UIColor *)fillColor NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * This generates a flat-color, rounded-corner resizeable image with a border @@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN cornerColor:(UIColor *)cornerColor fillColor:(UIColor *)fillColor borderColor:(nullable UIColor *)borderColor - borderWidth:(CGFloat)borderWidth AS_WARN_UNUSED_RESULT; + borderWidth:(CGFloat)borderWidth NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; /** * This generates a flat-color, rounded-corner resizeable image with a border @@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN borderColor:(nullable UIColor *)borderColor borderWidth:(CGFloat)borderWidth roundedCorners:(UIRectCorner)roundedCorners - scale:(CGFloat)scale AS_WARN_UNUSED_RESULT; + scale:(CGFloat)scale NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT; @end diff --git a/Source/UIImage+ASConvenience.m b/Source/UIImage+ASConvenience.m index 35e6f0d56..c1d0751e3 100644 --- a/Source/UIImage+ASConvenience.m +++ b/Source/UIImage+ASConvenience.m @@ -24,7 +24,7 @@ @implementation UIImage (ASDKFastImageNamed) -UIImage *cachedImageNamed(NSString *imageName, UITraitCollection *traitCollection) +UIImage *cachedImageNamed(NSString *imageName, UITraitCollection *traitCollection) NS_RETURNS_RETAINED { static NSCache *imageCache = nil; static dispatch_once_t onceToken; @@ -55,12 +55,12 @@ @implementation UIImage (ASDKFastImageNamed) return image; } -+ (UIImage *)as_imageNamed:(NSString *)imageName ++ (UIImage *)as_imageNamed:(NSString *)imageName NS_RETURNS_RETAINED { return cachedImageNamed(imageName, nil); } -+ (UIImage *)as_imageNamed:(NSString *)imageName compatibleWithTraitCollection:(UITraitCollection *)traitCollection ++ (UIImage *)as_imageNamed:(NSString *)imageName compatibleWithTraitCollection:(UITraitCollection *)traitCollection NS_RETURNS_RETAINED { return cachedImageNamed(imageName, traitCollection); } @@ -73,7 +73,7 @@ @implementation UIImage (ASDKResizableRoundedRects) + (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius cornerColor:(UIColor *)cornerColor - fillColor:(UIColor *)fillColor + fillColor:(UIColor *)fillColor NS_RETURNS_RETAINED { return [self as_resizableRoundedImageWithCornerRadius:cornerRadius cornerColor:cornerColor @@ -88,7 +88,7 @@ + (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius cornerColor:(UIColor *)cornerColor fillColor:(UIColor *)fillColor borderColor:(UIColor *)borderColor - borderWidth:(CGFloat)borderWidth + borderWidth:(CGFloat)borderWidth NS_RETURNS_RETAINED { return [self as_resizableRoundedImageWithCornerRadius:cornerRadius cornerColor:cornerColor @@ -105,7 +105,7 @@ + (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius borderColor:(UIColor *)borderColor borderWidth:(CGFloat)borderWidth roundedCorners:(UIRectCorner)roundedCorners - scale:(CGFloat)scale + scale:(CGFloat)scale NS_RETURNS_RETAINED { static NSCache *__pathCache = nil; static dispatch_once_t onceToken; diff --git a/Source/_ASTransitionContext.h b/Source/_ASTransitionContext.h index 2a8a6f14f..68eae7daa 100644 --- a/Source/_ASTransitionContext.h +++ b/Source/_ASTransitionContext.h @@ -53,5 +53,5 @@ @interface _ASAnimatedTransitionContext : NSObject @property (nonatomic, strong, readonly) ASDisplayNode *node; @property (nonatomic, assign, readonly) CGFloat alpha; -+ (instancetype)contextForNode:(ASDisplayNode *)node alpha:(CGFloat)alphaValue; ++ (instancetype)contextForNode:(ASDisplayNode *)node alpha:(CGFloat)alphaValue NS_RETURNS_RETAINED; @end diff --git a/Source/_ASTransitionContext.m b/Source/_ASTransitionContext.m index da6350a4a..169e11eaf 100644 --- a/Source/_ASTransitionContext.m +++ b/Source/_ASTransitionContext.m @@ -101,7 +101,7 @@ @interface _ASAnimatedTransitionContext () @implementation _ASAnimatedTransitionContext -+ (instancetype)contextForNode:(ASDisplayNode *)node alpha:(CGFloat)alpha ++ (instancetype)contextForNode:(ASDisplayNode *)node alpha:(CGFloat)alpha NS_RETURNS_RETAINED { _ASAnimatedTransitionContext *context = [[_ASAnimatedTransitionContext alloc] init]; context.node = node;