diff --git a/Source/ASCellNode.h b/Source/ASCellNode.h index 4957afdffb..36e5c46093 100644 --- a/Source/ASCellNode.h +++ b/Source/ASCellNode.h @@ -191,9 +191,9 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { @interface ASCellNode (Unavailable) -- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; - (void)setLayerBacked:(BOOL)layerBacked AS_UNAVAILABLE("ASCellNode does not support layer-backing"); @@ -208,7 +208,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { /** * Initializes a text cell with given text attributes and text insets */ -- (instancetype)initWithAttributes:(NSDictionary *)textAttributes insets:(UIEdgeInsets)textInsets; +- (instancetype)initWithAttributes:(NSDictionary *)textAttributes insets:(UIEdgeInsets)textInsets NS_DESIGNATED_INITIALIZER; /** * Text to display. diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index deeb1e1ca9..3b9a38a95a 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -125,7 +125,7 @@ extern NSInteger const ASDefaultDrawingPriority; * @return An ASDisplayNode instance whose view will be a subclass that enables asynchronous rendering, and passes * through -layout and touch handling methods. */ -- (instancetype)init; +- (instancetype)init NS_DESIGNATED_INITIALIZER; /** @@ -147,7 +147,7 @@ extern NSInteger const ASDefaultDrawingPriority; * @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. */ -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock; +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_DESIGNATED_INITIALIZER; /** * @abstract Alternative initializer with a block to create the backing layer. @@ -168,7 +168,7 @@ extern NSInteger const ASDefaultDrawingPriority; * @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. */ -- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock; +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_DESIGNATED_INITIALIZER; /** * @abstract Add a block of work to be performed on the main thread when the node's view or layer is loaded. Thread safe. diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index f1e134c800..fd7123b887 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -316,12 +316,11 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) - (instancetype)initWithViewClass:(Class)viewClass { - if (!(self = [super init])) + if (!(self = [self init])) return nil; ASDisplayNodeAssert([viewClass isSubclassOfClass:[UIView class]], @"should initialize with a subclass of UIView"); - [self _initializeInstance]; _viewClass = viewClass; _flags.synchronous = ![viewClass isSubclassOfClass:[_ASDisplayView class]]; @@ -330,12 +329,11 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) - (instancetype)initWithLayerClass:(Class)layerClass { - if (!(self = [super init])) + if (!(self = [self init])) return nil; ASDisplayNodeAssert([layerClass isSubclassOfClass:[CALayer class]], @"should initialize with a subclass of CALayer"); - [self _initializeInstance]; _layerClass = layerClass; _flags.synchronous = ![layerClass isSubclassOfClass:[_ASDisplayLayer class]]; _flags.layerBacked = YES; diff --git a/Source/ASEditableTextNode.h b/Source/ASEditableTextNode.h index 71d4a89da1..d395876ac1 100644 --- a/Source/ASEditableTextNode.h +++ b/Source/ASEditableTextNode.h @@ -136,9 +136,9 @@ NS_ASSUME_NONNULL_BEGIN @interface ASEditableTextNode (Unavailable) -- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; @end diff --git a/Source/ASMultiplexImageNode.h b/Source/ASMultiplexImageNode.h index 5320a461f4..6ea08c2c38 100644 --- a/Source/ASMultiplexImageNode.h +++ b/Source/ASMultiplexImageNode.h @@ -134,6 +134,16 @@ typedef NS_ENUM(NSUInteger, ASMultiplexImageNodeErrorCode) { #endif @end +#pragma mark - + +@interface ASMultiplexImageNode (Unavailable) + +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; + +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; + +@end + #pragma mark - /** diff --git a/Source/ASMultiplexImageNode.mm b/Source/ASMultiplexImageNode.mm index 0b3523c709..c26354f43a 100644 --- a/Source/ASMultiplexImageNode.mm +++ b/Source/ASMultiplexImageNode.mm @@ -149,7 +149,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent @implementation ASMultiplexImageNode -#pragma mark - Getting Started / Tearing Down +#pragma mark - Lifecycle + - (instancetype)initWithCache:(id)cache downloader:(id)downloader { if (!(self = [super init])) @@ -179,6 +180,18 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent #endif } +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock +{ + ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER(); + return [self init]; +} + +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock +{ + ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER(); + return [self init]; +} + - (void)dealloc { [_phImageRequestOperation cancel]; diff --git a/Source/ASNetworkImageNode.h b/Source/ASNetworkImageNode.h index 0f984eea37..4f3803aa77 100644 --- a/Source/ASNetworkImageNode.h +++ b/Source/ASNetworkImageNode.h @@ -112,6 +112,15 @@ NS_ASSUME_NONNULL_BEGIN @end +#pragma mark - + +@interface ASNetworkImageNode (Unavailable) + +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; + +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; + +@end #pragma mark - /** diff --git a/Source/ASNetworkImageNode.mm b/Source/ASNetworkImageNode.mm index 40e4bbf5b8..85b88bca76 100755 --- a/Source/ASNetworkImageNode.mm +++ b/Source/ASNetworkImageNode.mm @@ -102,6 +102,18 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0}; #endif } +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock +{ + ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER(); + return [self init]; +} + +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock +{ + ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER(); + return [self init]; +} + - (void)dealloc { [self _cancelImageDownload]; diff --git a/Source/ASScrollNode.mm b/Source/ASScrollNode.mm index 6e9afc69c7..9e110d0155 100644 --- a/Source/ASScrollNode.mm +++ b/Source/ASScrollNode.mm @@ -64,7 +64,7 @@ - (instancetype)init { - return [super initWithViewBlock:^UIView *{ return [[ASScrollView alloc] init]; }]; + return [super initWithViewBlock:^UIView *{ return [[ASScrollView alloc] init]; } didLoadBlock:nil]; } - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize diff --git a/Source/ASTextNode.h b/Source/ASTextNode.h index 78bdd12005..a5544d5a2f 100644 --- a/Source/ASTextNode.h +++ b/Source/ASTextNode.h @@ -282,9 +282,9 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) { @interface ASTextNode (Unavailable) -- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; @end diff --git a/Source/ASVideoNode.h b/Source/ASVideoNode.h index 63b8334338..d4f6bb7a3d 100644 --- a/Source/ASVideoNode.h +++ b/Source/ASVideoNode.h @@ -145,8 +145,11 @@ NS_ASSUME_NONNULL_BEGIN @interface ASVideoNode (Unavailable) -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable; +- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; + +- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; @end + NS_ASSUME_NONNULL_END diff --git a/Source/Details/ASAbstractLayoutController.h b/Source/Details/ASAbstractLayoutController.h index c79f13e8b3..0394fa70ef 100644 --- a/Source/Details/ASAbstractLayoutController.h +++ b/Source/Details/ASAbstractLayoutController.h @@ -29,9 +29,9 @@ ASDISPLAYNODE_EXTERN_C_END @interface ASAbstractLayoutController (Unavailable) -- (NSSet *)indexPathsForScrolling:(ASScrollDirection)scrollDirection rangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType __unavailable; +- (NSSet *)indexPathsForScrolling:(ASScrollDirection)scrollDirection rangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType NS_UNAVAILABLE; -- (void)allIndexPathsForScrolling:(ASScrollDirection)scrollDirection rangeMode:(ASLayoutRangeMode)rangeMode displaySet:(NSSet * _Nullable * _Nullable)displaySet preloadSet:(NSSet * _Nullable * _Nullable)preloadSet __unavailable; +- (void)allIndexPathsForScrolling:(ASScrollDirection)scrollDirection rangeMode:(ASLayoutRangeMode)rangeMode displaySet:(NSSet * _Nullable * _Nullable)displaySet preloadSet:(NSSet * _Nullable * _Nullable)preloadSet NS_UNAVAILABLE; @end diff --git a/Source/Layout/ASLayout.h b/Source/Layout/ASLayout.h index b592ddb13b..ca01744d2a 100644 --- a/Source/Layout/ASLayout.h +++ b/Source/Layout/ASLayout.h @@ -144,7 +144,7 @@ ASDISPLAYNODE_EXTERN_C_END @interface ASLayout (Unavailable) -- (instancetype)init __unavailable; +- (instancetype)init NS_UNAVAILABLE; @end diff --git a/Source/Layout/ASLayoutSpec+Subclasses.mm b/Source/Layout/ASLayoutSpec+Subclasses.mm index a743364ee5..083d1e14c9 100644 --- a/Source/Layout/ASLayoutSpec+Subclasses.mm +++ b/Source/Layout/ASLayoutSpec+Subclasses.mm @@ -14,7 +14,7 @@ #pragma mark - ASNullLayoutSpec @interface ASNullLayoutSpec : ASLayoutSpec -- (instancetype)init __unavailable; +- (instancetype)init NS_UNAVAILABLE; + (ASNullLayoutSpec *)null; @end diff --git a/Source/Layout/ASLayoutSpec.h b/Source/Layout/ASLayoutSpec.h index 4a28709d56..fe8bb67a9a 100644 --- a/Source/Layout/ASLayoutSpec.h +++ b/Source/Layout/ASLayoutSpec.h @@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN /* * Init not available for ASWrapperLayoutSpec */ -- (instancetype)init __unavailable; +- (instancetype)init NS_UNAVAILABLE; @end diff --git a/Source/Private/ASCollectionViewFlowLayoutInspector.h b/Source/Private/ASCollectionViewFlowLayoutInspector.h index 8505d3d7bd..edbdedcb68 100644 --- a/Source/Private/ASCollectionViewFlowLayoutInspector.h +++ b/Source/Private/ASCollectionViewFlowLayoutInspector.h @@ -24,6 +24,7 @@ AS_SUBCLASSING_RESTRICTED @property (nonatomic, weak, readonly) UICollectionViewFlowLayout *layout; - (instancetype)init NS_UNAVAILABLE; + - (instancetype)initWithFlowLayout:(UICollectionViewFlowLayout *)flowLayout NS_DESIGNATED_INITIALIZER; @end diff --git a/Source/Private/ASLayoutTransition.h b/Source/Private/ASLayoutTransition.h index f3e384e901..52a05834d0 100644 --- a/Source/Private/ASLayoutTransition.h +++ b/Source/Private/ASLayoutTransition.h @@ -93,7 +93,7 @@ AS_SUBCLASSING_RESTRICTED @interface ASLayoutTransition (Unavailable) -- (instancetype)init __unavailable; +- (instancetype)init NS_UNAVAILABLE; @end diff --git a/Source/Private/ASMutableElementMap.h b/Source/Private/ASMutableElementMap.h index 221353e573..b6f9f22ea4 100644 --- a/Source/Private/ASMutableElementMap.h +++ b/Source/Private/ASMutableElementMap.h @@ -21,8 +21,6 @@ NS_ASSUME_NONNULL_BEGIN AS_SUBCLASSING_RESTRICTED @interface ASMutableElementMap : NSObject -- (instancetype)init __unavailable; - - (instancetype)initWithSections:(NSArray *)sections items:(ASCollectionElementTwoDimensionalArray *)items supplementaryElements:(ASSupplementaryElementDictionary *)supplementaryElements; - (void)insertSection:(ASSection *)section atIndex:(NSInteger)index; @@ -49,4 +47,10 @@ AS_SUBCLASSING_RESTRICTED @interface ASElementMap (MutableCopying) @end +@interface ASMutableElementMap (Unavailable) + +- (instancetype)init NS_UNAVAILABLE; + +@end + NS_ASSUME_NONNULL_END diff --git a/Source/Private/ASSection.h b/Source/Private/ASSection.h index 4944415d5b..42f71e2ce4 100644 --- a/Source/Private/ASSection.h +++ b/Source/Private/ASSection.h @@ -19,7 +19,7 @@ @property (nonatomic, assign, readonly) NSInteger sectionID; @property (nonatomic, strong, nullable, readonly) id context; -- (nullable instancetype)init __unavailable; +- (nullable instancetype)init NS_UNAVAILABLE; - (nullable instancetype)initWithSectionID:(NSInteger)sectionID context:(nullable id)context NS_DESIGNATED_INITIALIZER; @end