Merge pull request #1528 from ejensen/instancetype

[Refactoring] Replace id with instancetype in initializers
This commit is contained in:
appleguy
2016-04-16 20:53:41 -07:00
12 changed files with 32 additions and 32 deletions

View File

@@ -80,7 +80,7 @@ static BOOL _enableHitTestDebug = NO;
#pragma mark - Lifecycle #pragma mark - Lifecycle
- (id)init - (instancetype)init
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;

View File

@@ -256,7 +256,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
_environmentState = ASEnvironmentStateMakeDefault(); _environmentState = ASEnvironmentStateMakeDefault();
} }
- (id)init - (instancetype)init
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;
@@ -266,7 +266,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return self; return self;
} }
- (id)initWithViewClass:(Class)viewClass - (instancetype)initWithViewClass:(Class)viewClass
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;
@@ -280,7 +280,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return self; return self;
} }
- (id)initWithLayerClass:(Class)layerClass - (instancetype)initWithLayerClass:(Class)layerClass
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;
@@ -295,12 +295,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return self; return self;
} }
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock - (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
{ {
return [self initWithViewBlock:viewBlock didLoadBlock:nil]; return [self initWithViewBlock:viewBlock didLoadBlock:nil];
} }
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock - (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;
@@ -315,12 +315,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return self; return self;
} }
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
{ {
return [self initWithLayerBlock:layerBlock didLoadBlock:nil]; return [self initWithLayerBlock:layerBlock didLoadBlock:nil];
} }
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;

View File

@@ -39,7 +39,7 @@
// TODO: eliminate explicit parameters with a set of keys copied from the node // TODO: eliminate explicit parameters with a set of keys copied from the node
@implementation _ASImageNodeDrawParameters @implementation _ASImageNodeDrawParameters
- (id)initWithImage:(UIImage *)image - (instancetype)initWithImage:(UIImage *)image
bounds:(CGRect)bounds bounds:(CGRect)bounds
opaque:(BOOL)opaque opaque:(BOOL)opaque
contentsScale:(CGFloat)contentsScale contentsScale:(CGFloat)contentsScale
@@ -86,7 +86,7 @@
@synthesize image = _image; @synthesize image = _image;
@synthesize imageModificationBlock = _imageModificationBlock; @synthesize imageModificationBlock = _imageModificationBlock;
- (id)init - (instancetype)init
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;

View File

@@ -20,14 +20,14 @@ NS_ASSUME_NONNULL_BEGIN
@param rects Array containing CGRects wrapped in NSValue. @param rects Array containing CGRects wrapped in NSValue.
@param targetLayer The layer that the rects are relative to. The rects will be translated to the receiver's coordinate space when rendering. @param targetLayer The layer that the rects are relative to. The rects will be translated to the receiver's coordinate space when rendering.
*/ */
- (id)initWithRects:(NSArray<NSValue *> *)rects targetLayer:(nullable CALayer *)targetLayer; - (instancetype)initWithRects:(NSArray<NSValue *> *)rects targetLayer:(nullable CALayer *)targetLayer;
/** /**
@summary Initializes with CGRects for the highlighting, in the receiver's coordinate space. @summary Initializes with CGRects for the highlighting, in the receiver's coordinate space.
@param rects Array containing CGRects wrapped in NSValue. @param rects Array containing CGRects wrapped in NSValue.
*/ */
- (id)initWithRects:(NSArray<NSValue *> *)rects; - (instancetype)initWithRects:(NSArray<NSValue *> *)rects;
@property (nullable, atomic, strong) __attribute__((NSObject)) CGColorRef highlightColor; @property (nullable, atomic, strong) __attribute__((NSObject)) CGColorRef highlightColor;
@property (atomic, weak) CALayer *targetLayer; @property (atomic, weak) CALayer *targetLayer;

View File

@@ -49,12 +49,12 @@ static const UIEdgeInsets padding = {2, 4, 1.5, 4};
return (id<CAAction>)[NSNull null]; return (id<CAAction>)[NSNull null];
} }
- (id)initWithRects:(NSArray *)rects - (instancetype)initWithRects:(NSArray *)rects
{ {
return [self initWithRects:rects targetLayer:nil]; return [self initWithRects:rects targetLayer:nil];
} }
- (id)initWithRects:(NSArray *)rects targetLayer:(id)targetLayer - (instancetype)initWithRects:(NSArray *)rects targetLayer:(id)targetLayer
{ {
if (self = [super init]) { if (self = [super init]) {
_rects = [rects copy]; _rects = [rects copy];

View File

@@ -54,7 +54,7 @@ extern NSInteger const ASDefaultTransactionPriority;
@param callbackQueue The dispatch queue that the completion blocks will be called on. @param callbackQueue The dispatch queue that the completion blocks will be called on.
@param completionBlock A block that is called when the transaction is completed. May be NULL. @param completionBlock A block that is called when the transaction is completed. May be NULL.
*/ */
- (id)initWithCallbackQueue:(dispatch_queue_t)callbackQueue - (instancetype)initWithCallbackQueue:(dispatch_queue_t)callbackQueue
completionBlock:(asyncdisplaykit_async_transaction_completion_block_t)completionBlock; completionBlock:(asyncdisplaykit_async_transaction_completion_block_t)completionBlock;
/** /**

View File

@@ -16,14 +16,14 @@
NSInteger const ASDefaultTransactionPriority = 0; NSInteger const ASDefaultTransactionPriority = 0;
@interface ASDisplayNodeAsyncTransactionOperation : NSObject @interface ASDisplayNodeAsyncTransactionOperation : NSObject
- (id)initWithOperationCompletionBlock:(asyncdisplaykit_async_transaction_operation_completion_block_t)operationCompletionBlock; - (instancetype)initWithOperationCompletionBlock:(asyncdisplaykit_async_transaction_operation_completion_block_t)operationCompletionBlock;
@property (nonatomic, copy) asyncdisplaykit_async_transaction_operation_completion_block_t operationCompletionBlock; @property (nonatomic, copy) asyncdisplaykit_async_transaction_operation_completion_block_t operationCompletionBlock;
@property (atomic, strong) id<NSObject> value; // set on bg queue by the operation block @property (atomic, strong) id<NSObject> value; // set on bg queue by the operation block
@end @end
@implementation ASDisplayNodeAsyncTransactionOperation @implementation ASDisplayNodeAsyncTransactionOperation
- (id)initWithOperationCompletionBlock:(asyncdisplaykit_async_transaction_operation_completion_block_t)operationCompletionBlock - (instancetype)initWithOperationCompletionBlock:(asyncdisplaykit_async_transaction_operation_completion_block_t)operationCompletionBlock
{ {
if ((self = [super init])) { if ((self = [super init])) {
_operationCompletionBlock = [operationCompletionBlock copy]; _operationCompletionBlock = [operationCompletionBlock copy];
@@ -315,7 +315,7 @@ ASAsyncTransactionQueue & ASAsyncTransactionQueue::instance()
#pragma mark - #pragma mark -
#pragma mark Lifecycle #pragma mark Lifecycle
- (id)initWithCallbackQueue:(dispatch_queue_t)callbackQueue - (instancetype)initWithCallbackQueue:(dispatch_queue_t)callbackQueue
completionBlock:(void(^)(_ASAsyncTransaction *, BOOL))completionBlock completionBlock:(void(^)(_ASAsyncTransaction *, BOOL))completionBlock
{ {
if ((self = [self init])) { if ((self = [self init])) {

View File

@@ -62,7 +62,7 @@ static void _transactionGroupRunLoopObserverCallback(CFRunLoopObserverRef observ
CFRelease(observer); CFRelease(observer);
} }
- (id)init - (instancetype)init
{ {
if ((self = [super init])) { if ((self = [super init])) {
_containerLayers = [NSHashTable hashTableWithOptions:NSPointerFunctionsObjectPointerPersonality]; _containerLayers = [NSHashTable hashTableWithOptions:NSPointerFunctionsObjectPointerPersonality];

View File

@@ -31,7 +31,7 @@
#pragma mark - #pragma mark -
#pragma mark Lifecycle #pragma mark Lifecycle
- (id)init - (instancetype)init
{ {
if ((self = [super init])) { if ((self = [super init])) {
_displaySentinel = [[ASSentinel alloc] init]; _displaySentinel = [[ASSentinel alloc] init];

View File

@@ -37,7 +37,7 @@
} }
#pragma mark - NSObject Overrides #pragma mark - NSObject Overrides
- (id)init - (instancetype)init
{ {
return [self initWithFrame:CGRectZero]; return [self initWithFrame:CGRectZero];
} }
@@ -51,7 +51,7 @@
#pragma mark - UIView Overrides #pragma mark - UIView Overrides
- (id)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if (!(self = [super initWithFrame:frame])) if (!(self = [super initWithFrame:frame]))
return nil; return nil;

View File

@@ -193,10 +193,10 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
- (void)displayImmediately; - (void)displayImmediately;
// Alternative initialiser for backing with a custom view class. Supports asynchronous display with _ASDisplayView subclasses. // Alternative initialiser for backing with a custom view class. Supports asynchronous display with _ASDisplayView subclasses.
- (id)initWithViewClass:(Class)viewClass; - (instancetype)initWithViewClass:(Class)viewClass;
// Alternative initialiser for backing with a custom layer class. Supports asynchronous display with _ASDisplayLayer subclasses. // Alternative initialiser for backing with a custom layer class. Supports asynchronous display with _ASDisplayLayer subclasses.
- (id)initWithLayerClass:(Class)layerClass; - (instancetype)initWithLayerClass:(Class)layerClass;
@property (nonatomic, assign) CGFloat contentsScaleForDisplay; @property (nonatomic, assign) CGFloat contentsScaleForDisplay;

View File

@@ -179,7 +179,7 @@ ASDISPLAYNODE_INLINE void ASPendingStateApplyMetricsToLayer(_ASPendingState *sta
static CGColorRef blackColorRef = NULL; static CGColorRef blackColorRef = NULL;
static UIColor *defaultTintColor = nil; static UIColor *defaultTintColor = nil;
- (id)init - (instancetype)init
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;