Merge pull request #1354 from ejensen/cleanup

[Refactoring] Objective-C 2.0 / Modern syntax for arrays, dictionaries, numbers; logic simplification
This commit is contained in:
appleguy
2016-03-17 01:06:33 -07:00
25 changed files with 54 additions and 73 deletions

View File

@@ -271,8 +271,8 @@
- (void)setTitle:(NSString *)title withFont:(UIFont *)font withColor:(UIColor *)color forState:(ASControlState)state - (void)setTitle:(NSString *)title withFont:(UIFont *)font withColor:(UIColor *)color forState:(ASControlState)state
{ {
NSDictionary *attributes = @{ NSDictionary *attributes = @{
NSFontAttributeName: font ? font :[UIFont systemFontOfSize:[UIFont buttonFontSize]], NSFontAttributeName: font ?: [UIFont systemFontOfSize:[UIFont buttonFontSize]],
NSForegroundColorAttributeName : color ? color : [UIColor blackColor] NSForegroundColorAttributeName : color ?: [UIColor blackColor]
}; };
NSAttributedString *string = [[NSAttributedString alloc] initWithString:title NSAttributedString *string = [[NSAttributedString alloc] initWithString:title

View File

@@ -257,13 +257,13 @@ static BOOL _enableHitTestDebug = NO;
{ {
// Do we already have an event table for this control event? // Do we already have an event table for this control event?
id<NSCopying> eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent); id<NSCopying> eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent);
NSMapTable *eventDispatchTable = [_controlEventDispatchTable objectForKey:eventKey]; NSMapTable *eventDispatchTable = _controlEventDispatchTable[eventKey];
// Create it if necessary. // Create it if necessary.
if (!eventDispatchTable) if (!eventDispatchTable)
{ {
// Create the dispatch table for this event. // Create the dispatch table for this event.
eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable]; eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable];
[_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey]; _controlEventDispatchTable[eventKey] = eventDispatchTable;
} }
// Have we seen this target before for this event? // Have we seen this target before for this event?
@@ -291,7 +291,7 @@ static BOOL _enableHitTestDebug = NO;
ASDN::MutexLocker l(_controlLock); ASDN::MutexLocker l(_controlLock);
// Grab the event dispatch table for this event. // Grab the event dispatch table for this event.
NSMapTable *eventDispatchTable = [_controlEventDispatchTable objectForKey:_ASControlNodeEventKeyForControlEvent(controlEvent)]; NSMapTable *eventDispatchTable = _controlEventDispatchTable[_ASControlNodeEventKeyForControlEvent(controlEvent)];
if (!eventDispatchTable) if (!eventDispatchTable)
return nil; return nil;
@@ -328,7 +328,7 @@ static BOOL _enableHitTestDebug = NO;
{ {
// Grab the dispatch table for this event (if we have it). // Grab the dispatch table for this event (if we have it).
id<NSCopying> eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent); id<NSCopying> eventKey = _ASControlNodeEventKeyForControlEvent(controlEvent);
NSMapTable *eventDispatchTable = [_controlEventDispatchTable objectForKey:eventKey]; NSMapTable *eventDispatchTable = _controlEventDispatchTable[eventKey];
if (!eventDispatchTable) if (!eventDispatchTable)
return; return;
@@ -381,7 +381,7 @@ static BOOL _enableHitTestDebug = NO;
(ASControlNodeEvent controlEvent) (ASControlNodeEvent controlEvent)
{ {
// Use a copy to itereate, the action perform could call remove causing a mutation crash. // Use a copy to itereate, the action perform could call remove causing a mutation crash.
NSMapTable *eventDispatchTable = [[_controlEventDispatchTable objectForKey:_ASControlNodeEventKeyForControlEvent(controlEvent)] copy]; NSMapTable *eventDispatchTable = [_controlEventDispatchTable[_ASControlNodeEventKeyForControlEvent(controlEvent)] copy];
// For each target interested in this event... // For each target interested in this event...
for (id target in eventDispatchTable) for (id target in eventDispatchTable)
@@ -413,7 +413,7 @@ static BOOL _enableHitTestDebug = NO;
id<NSCopying> _ASControlNodeEventKeyForControlEvent(ASControlNodeEvent controlEvent) id<NSCopying> _ASControlNodeEventKeyForControlEvent(ASControlNodeEvent controlEvent)
{ {
return [NSNumber numberWithInteger:controlEvent]; return @(controlEvent);
} }
void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent)) void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent))

View File

@@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN
* @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as * @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as
* well. * well.
*/ */
@property (nonatomic, readonly, retain) UIView *view; @property (nonatomic, readonly, strong) UIView *view;
/** /**
* @abstract Returns whether a node's backing view or layer is loaded. * @abstract Returns whether a node's backing view or layer is loaded.
@@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
* @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as * @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as
* well. * well.
*/ */
@property (nonatomic, readonly, retain) CALayer * _Nonnull layer; @property (nonatomic, readonly, strong) CALayer * _Nonnull layer;
/** /**
* @abstract Returns the Interface State of the node. * @abstract Returns the Interface State of the node.
@@ -351,7 +351,7 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* @abstract The receiver's immediate subnodes. * @abstract The receiver's immediate subnodes.
*/ */
@property (nonatomic, readonly, retain) NSArray<ASDisplayNode *> *subnodes; @property (nonatomic, readonly, strong) NSArray<ASDisplayNode *> *subnodes;
/** /**
* @abstract The receiver's supernode. * @abstract The receiver's supernode.
@@ -622,7 +622,7 @@ NS_ASSUME_NONNULL_END
*/ */
- (void)setNeedsLayout; - (void)setNeedsLayout;
@property (atomic, retain, nullable) id contents; // default=nil @property (atomic, strong, nullable) id contents; // default=nil
@property (atomic, assign) BOOL clipsToBounds; // default==NO @property (atomic, assign) BOOL clipsToBounds; // default==NO
@property (atomic, getter=isOpaque) BOOL opaque; // default==YES @property (atomic, getter=isOpaque) BOOL opaque; // default==YES
@@ -650,9 +650,9 @@ NS_ASSUME_NONNULL_END
* @discussion In contrast to UIView, setting a transparent color will not set opaque = NO. * @discussion In contrast to UIView, setting a transparent color will not set opaque = NO.
* This only affects nodes that implement +drawRect like ASTextNode. * This only affects nodes that implement +drawRect like ASTextNode.
*/ */
@property (atomic, retain, nullable) UIColor *backgroundColor; // default=nil @property (atomic, strong, nullable) UIColor *backgroundColor; // default=nil
@property (atomic, retain, null_resettable) UIColor *tintColor; // default=Blue @property (atomic, strong, null_resettable) UIColor *tintColor; // default=Blue
- (void)tintColorDidChange; // Notifies the node when the tintColor has changed. - (void)tintColorDidChange; // Notifies the node when the tintColor has changed.
/** /**
@@ -702,7 +702,7 @@ NS_ASSUME_NONNULL_END
@property (nullable, atomic, copy) NSString *accessibilityValue; @property (nullable, atomic, copy) NSString *accessibilityValue;
@property (atomic, assign) UIAccessibilityTraits accessibilityTraits; @property (atomic, assign) UIAccessibilityTraits accessibilityTraits;
@property (atomic, assign) CGRect accessibilityFrame; @property (atomic, assign) CGRect accessibilityFrame;
@property (nullable, atomic, retain) NSString *accessibilityLanguage; @property (nullable, atomic, strong) NSString *accessibilityLanguage;
@property (atomic, assign) BOOL accessibilityElementsHidden; @property (atomic, assign) BOOL accessibilityElementsHidden;
@property (atomic, assign) BOOL accessibilityViewIsModal; @property (atomic, assign) BOOL accessibilityViewIsModal;
@property (atomic, assign) BOOL shouldGroupAccessibilityChildren; @property (atomic, assign) BOOL shouldGroupAccessibilityChildren;

View File

@@ -225,7 +225,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
if (isQueueDrained) { if (isQueueDrained) {
[[NSNotificationCenter defaultCenter] postNotificationName:ASRenderingEngineDidDisplayScheduledNodesNotification [[NSNotificationCenter defaultCenter] postNotificationName:ASRenderingEngineDidDisplayScheduledNodesNotification
object:nil object:nil
userInfo:@{ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp: [NSNumber numberWithDouble:timestamp]}]; userInfo:@{ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp: @(timestamp)}];
} }
}]; }];
}); });
@@ -1062,7 +1062,7 @@ static inline CATransform3D _calculateTransformFromReferenceToTarget(ASDisplayNo
{ {
ASDisplayNodeAssertThreadAffinity(self); ASDisplayNodeAssertThreadAffinity(self);
// Get root node of the accessible node hierarchy, if node not specified // Get root node of the accessible node hierarchy, if node not specified
node = node ? node : ASDisplayNodeUltimateParentOfNode(self); node = node ?: ASDisplayNodeUltimateParentOfNode(self);
// Calculate transform to map points between coordinate spaces // Calculate transform to map points between coordinate spaces
CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(node, self); CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(node, self);
@@ -1077,7 +1077,7 @@ static inline CATransform3D _calculateTransformFromReferenceToTarget(ASDisplayNo
{ {
ASDisplayNodeAssertThreadAffinity(self); ASDisplayNodeAssertThreadAffinity(self);
// Get root node of the accessible node hierarchy, if node not specified // Get root node of the accessible node hierarchy, if node not specified
node = node ? node : ASDisplayNodeUltimateParentOfNode(self); node = node ?: ASDisplayNodeUltimateParentOfNode(self);
// Calculate transform to map points between coordinate spaces // Calculate transform to map points between coordinate spaces
CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(self, node); CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(self, node);
@@ -1092,7 +1092,7 @@ static inline CATransform3D _calculateTransformFromReferenceToTarget(ASDisplayNo
{ {
ASDisplayNodeAssertThreadAffinity(self); ASDisplayNodeAssertThreadAffinity(self);
// Get root node of the accessible node hierarchy, if node not specified // Get root node of the accessible node hierarchy, if node not specified
node = node ? node : ASDisplayNodeUltimateParentOfNode(self); node = node ?: ASDisplayNodeUltimateParentOfNode(self);
// Calculate transform to map points between coordinate spaces // Calculate transform to map points between coordinate spaces
CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(node, self); CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(node, self);
@@ -1107,7 +1107,7 @@ static inline CATransform3D _calculateTransformFromReferenceToTarget(ASDisplayNo
{ {
ASDisplayNodeAssertThreadAffinity(self); ASDisplayNodeAssertThreadAffinity(self);
// Get root node of the accessible node hierarchy, if node not specified // Get root node of the accessible node hierarchy, if node not specified
node = node ? node : ASDisplayNodeUltimateParentOfNode(self); node = node ?: ASDisplayNodeUltimateParentOfNode(self);
// Calculate transform to map points between coordinate spaces // Calculate transform to map points between coordinate spaces
CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(self, node); CATransform3D nodeTransform = _calculateTransformFromReferenceToTarget(self, node);
@@ -2079,11 +2079,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
BOOL wasVisible = ASInterfaceStateIncludesVisible(oldState); BOOL wasVisible = ASInterfaceStateIncludesVisible(oldState);
if (nowVisible != wasVisible) { if (nowVisible != wasVisible) {
if (nowVisible) { [self visibilityDidChange:nowVisible];
[self visibilityDidChange:YES];
} else {
[self visibilityDidChange:NO];
}
} }
[self interfaceStateDidChange:newState fromState:oldState]; [self interfaceStateDidChange:newState fromState:oldState];
@@ -2528,7 +2524,7 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority";
objc_setAssociatedObject(self, ASDisplayNodeDrawingPriorityKey, nil, OBJC_ASSOCIATION_ASSIGN); objc_setAssociatedObject(self, ASDisplayNodeDrawingPriorityKey, nil, OBJC_ASSOCIATION_ASSIGN);
} else { } else {
_flags.hasCustomDrawingPriority = YES; _flags.hasCustomDrawingPriority = YES;
objc_setAssociatedObject(self, ASDisplayNodeDrawingPriorityKey, [NSNumber numberWithInteger:drawingPriority], OBJC_ASSOCIATION_RETAIN); objc_setAssociatedObject(self, ASDisplayNodeDrawingPriorityKey, @(drawingPriority), OBJC_ASSOCIATION_RETAIN);
} }
} }

View File

@@ -10,11 +10,6 @@
#import "ASEqualityHashHelpers.h" #import "ASEqualityHashHelpers.h"
#import <functional>
#import <objc/runtime.h>
#import <stdio.h>
#import <string>
NSUInteger ASIntegerArrayHash(const NSUInteger *subhashes, NSUInteger count) NSUInteger ASIntegerArrayHash(const NSUInteger *subhashes, NSUInteger count)
{ {
uint64_t result = subhashes[0]; uint64_t result = subhashes[0];

View File

@@ -33,7 +33,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
* the layer's contentsCenter property. Non-stretchable images work too, of * the layer's contentsCenter property. Non-stretchable images work too, of
* course. * course.
*/ */
@property (nullable, atomic, retain) UIImage *image; @property (nullable, atomic, strong) UIImage *image;
/** /**
@abstract The placeholder color. @abstract The placeholder color.

View File

@@ -28,7 +28,7 @@
@property (nonatomic, assign) BOOL opaque; @property (nonatomic, assign) BOOL opaque;
@property (nonatomic, assign) CGRect bounds; @property (nonatomic, assign) CGRect bounds;
@property (nonatomic, assign) CGFloat contentsScale; @property (nonatomic, assign) CGFloat contentsScale;
@property (nonatomic, retain) UIColor *backgroundColor; @property (nonatomic, strong) UIColor *backgroundColor;
@property (nonatomic, assign) UIViewContentMode contentMode; @property (nonatomic, assign) UIViewContentMode contentMode;
@end @end

View File

@@ -53,7 +53,6 @@
{ {
std::deque<id> itemsToProcess = std::deque<id>(); std::deque<id> itemsToProcess = std::deque<id>();
BOOL isQueueDrained = NO; BOOL isQueueDrained = NO;
CFAbsoluteTime timestamp = 0;
{ {
ASDN::MutexLocker l(_internalQueueLock); ASDN::MutexLocker l(_internalQueueLock);
@@ -72,7 +71,6 @@
if (_internalQueue.empty()) { if (_internalQueue.empty()) {
isQueueDrained = YES; isQueueDrained = YES;
timestamp = CFAbsoluteTimeGetCurrent();
} }
} }

View File

@@ -120,13 +120,13 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
} }
@property (atomic, assign) BOOL asyncDataSourceLocked; @property (atomic, assign) BOOL asyncDataSourceLocked;
@property (nonatomic, retain, readwrite) ASDataController *dataController; @property (nonatomic, strong, readwrite) ASDataController *dataController;
// Used only when ASTableView is created directly rather than through ASTableNode. // Used only when ASTableView is created directly rather than through ASTableNode.
// We create a node so that logic related to appearance, memory management, etc can be located there // We create a node so that logic related to appearance, memory management, etc can be located there
// for both the node-based and view-based version of the table. // for both the node-based and view-based version of the table.
// This also permits sharing logic with ASCollectionNode, as the superclass is not UIKit-controlled. // This also permits sharing logic with ASCollectionNode, as the superclass is not UIKit-controlled.
@property (nonatomic, retain) ASTableNode *strongTableNode; @property (nonatomic, strong) ASTableNode *strongTableNode;
// Always set, whether ASCollectionView is created directly or via ASCollectionNode. // Always set, whether ASCollectionView is created directly or via ASCollectionNode.
@property (nonatomic, weak) ASTableNode *tableNode; @property (nonatomic, weak) ASTableNode *tableNode;

View File

@@ -12,7 +12,7 @@
@interface ASTableView (Internal) @interface ASTableView (Internal)
@property (nonatomic, retain, readonly) ASDataController *dataController; @property (nonatomic, strong, readonly) ASDataController *dataController;
@property (nonatomic, weak, readwrite) ASTableNode *tableNode; @property (nonatomic, weak, readwrite) ASTableNode *tableNode;
@property (nonatomic, strong, readonly) ASRangeController *rangeController; @property (nonatomic, strong, readonly) ASRangeController *rangeController;

View File

@@ -475,7 +475,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
// Final output vars // Final output vars
__block id linkAttributeValue = nil; __block id linkAttributeValue = nil;
__block NSString *linkAttributeName = nil;
__block BOOL inTruncationMessage = NO; __block BOOL inTruncationMessage = NO;
[renderer enumerateTextIndexesAtPosition:point usingBlock:^(NSUInteger characterIndex, CGRect glyphBoundingRect, BOOL *stop) { [renderer enumerateTextIndexesAtPosition:point usingBlock:^(NSUInteger characterIndex, CGRect glyphBoundingRect, BOOL *stop) {
@@ -544,7 +543,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
// Set the values for the next iteration // Set the values for the next iteration
linkAttributeValue = value; linkAttributeValue = value;
linkAttributeName = name;
break; break;
} }

View File

@@ -80,14 +80,14 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{ {
if ([[change objectForKey:@"new"] integerValue] == AVPlayerItemStatusReadyToPlay) { if ([change[@"new"] integerValue] == AVPlayerItemStatusReadyToPlay) {
if ([self.subnodes containsObject:_spinner]) { if ([self.subnodes containsObject:_spinner]) {
[_spinner removeFromSupernode]; [_spinner removeFromSupernode];
_spinner = nil; _spinner = nil;
} }
} }
if ([[change objectForKey:@"new"] integerValue] == AVPlayerItemStatusFailed) { if ([change[@"new"] integerValue] == AVPlayerItemStatusFailed) {
} }
} }

View File

@@ -104,11 +104,7 @@
- (BOOL)layoutHasSupplementaryViewOfKind:(NSString *)kind inSection:(NSUInteger)section collectionView:(ASCollectionView *)collectionView - (BOOL)layoutHasSupplementaryViewOfKind:(NSString *)kind inSection:(NSUInteger)section collectionView:(ASCollectionView *)collectionView
{ {
CGSize size = [self sizeForSupplementaryViewOfKind:kind inSection:section collectionView:collectionView]; CGSize size = [self sizeForSupplementaryViewOfKind:kind inSection:section collectionView:collectionView];
if ([self usedLayoutValueForSize:size] > 0) { return [self usedLayoutValueForSize:size] > 0;
return YES;
} else {
return NO;
}
} }
- (CGFloat)usedLayoutValueForSize:(CGSize)size - (CGFloat)usedLayoutValueForSize:(CGSize)size

View File

@@ -876,12 +876,12 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
[_editingTransactionQueue addOperationWithBlock:^{ [_editingTransactionQueue addOperationWithBlock:^{
LOG(@"Edit Transaction - moveRow: %@ > %@", indexPath, newIndexPath); LOG(@"Edit Transaction - moveRow: %@ > %@", indexPath, newIndexPath);
NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths(_editingNodes[ASDataControllerRowNodeKind], [NSArray arrayWithObject:indexPath]); NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths(_editingNodes[ASDataControllerRowNodeKind], @[indexPath]);
NSArray *indexPaths = [NSArray arrayWithObject:indexPath]; NSArray *indexPaths = @[indexPath];
[self _deleteNodesAtIndexPaths:indexPaths withAnimationOptions:animationOptions]; [self _deleteNodesAtIndexPaths:indexPaths withAnimationOptions:animationOptions];
// Don't re-calculate size for moving // Don't re-calculate size for moving
NSArray *newIndexPaths = [NSArray arrayWithObject:newIndexPath]; NSArray *newIndexPaths = @[newIndexPath];
[self _insertNodes:nodes atIndexPaths:newIndexPaths withAnimationOptions:animationOptions]; [self _insertNodes:nodes atIndexPaths:newIndexPaths withAnimationOptions:animationOptions];
}]; }];
}]; }];
@@ -967,7 +967,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
- (NSArray *)completedNodes - (NSArray *)completedNodes
{ {
ASDisplayNodeAssertMainThread(); ASDisplayNodeAssertMainThread();
return _externalCompletedNodes != nil ? _externalCompletedNodes : _completedNodes[ASDataControllerRowNodeKind]; return _externalCompletedNodes ?: _completedNodes[ASDataControllerRowNodeKind];
} }
#pragma mark - Dealloc #pragma mark - Dealloc

View File

@@ -45,7 +45,7 @@
ASDN::MutexLocker l(_serialQueueLock); ASDN::MutexLocker l(_serialQueueLock);
dispatch_block_t block; dispatch_block_t block;
if (_blocks.count > 0) { if (_blocks.count > 0) {
block = [_blocks objectAtIndex:0]; block = _blocks[0];
[_blocks removeObjectAtIndex:0]; [_blocks removeObjectAtIndex:0];
} else { } else {
break; break;

View File

@@ -293,13 +293,13 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
if (section != currentSectionIndex) { if (section != currentSectionIndex) {
// Often we'll be dealing with indexPaths in the same section, but the set isn't sorted and we may even bounce // Often we'll be dealing with indexPaths in the same section, but the set isn't sorted and we may even bounce
// between the same ones. Still, this saves dozens of method calls to access the inner array and count. // between the same ones. Still, this saves dozens of method calls to access the inner array and count.
currentSectionNodes = [allNodes objectAtIndex:section]; currentSectionNodes = allNodes[section];
numberOfNodesInSection = [currentSectionNodes count]; numberOfNodesInSection = [currentSectionNodes count];
currentSectionIndex = section; currentSectionIndex = section;
} }
if (row < numberOfNodesInSection) { if (row < numberOfNodesInSection) {
ASDisplayNode *node = [currentSectionNodes objectAtIndex:row]; ASDisplayNode *node = currentSectionNodes[row];
ASDisplayNodeAssert(node.hierarchyState & ASHierarchyStateRangeManaged, @"All nodes reaching this point should be range-managed, or interfaceState may be incorrectly reset."); ASDisplayNodeAssert(node.hierarchyState & ASHierarchyStateRangeManaged, @"All nodes reaching this point should be range-managed, or interfaceState may be incorrectly reset.");
// Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState. // Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState.
@@ -352,7 +352,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
- (void)scheduledNodesDidDisplay:(NSNotification *)notification - (void)scheduledNodesDidDisplay:(NSNotification *)notification
{ {
CFAbsoluteTime notificationTimestamp = ((NSNumber *)[notification.userInfo objectForKey:ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp]).doubleValue; CFAbsoluteTime notificationTimestamp = ((NSNumber *) notification.userInfo[ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp]).doubleValue;
if (_pendingDisplayNodesTimestamp < notificationTimestamp) { if (_pendingDisplayNodesTimestamp < notificationTimestamp) {
// The rendering engine has processed all the nodes this range controller scheduled. Let's schedule a range update // The rendering engine has processed all the nodes this range controller scheduled. Let's schedule a range update
[[NSNotificationCenter defaultCenter] removeObserver:self name:ASRenderingEngineDidDisplayScheduledNodesNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:ASRenderingEngineDidDisplayScheduledNodesNotification object:nil];

View File

@@ -18,7 +18,7 @@ NSInteger const ASDefaultTransactionPriority = 0;
@interface ASDisplayNodeAsyncTransactionOperation : NSObject @interface ASDisplayNodeAsyncTransactionOperation : NSObject
- (id)initWithOperationCompletionBlock:(asyncdisplaykit_async_transaction_operation_completion_block_t)operationCompletionBlock; - (id)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, retain) 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

View File

@@ -10,8 +10,8 @@
@interface CALayer (ASAsyncTransactionContainerTransactions) @interface CALayer (ASAsyncTransactionContainerTransactions)
@property (nonatomic, retain, setter=asyncdisplaykit_setAsyncLayerTransactions:) NSHashTable *asyncdisplaykit_asyncLayerTransactions; @property (nonatomic, strong, setter=asyncdisplaykit_setAsyncLayerTransactions:) NSHashTable *asyncdisplaykit_asyncLayerTransactions;
@property (nonatomic, retain, setter=asyncdisplaykit_setCurrentAsyncLayerTransaction:) _ASAsyncTransaction *asyncdisplaykit_currentAsyncLayerTransaction; @property (nonatomic, strong, setter=asyncdisplaykit_setCurrentAsyncLayerTransaction:) _ASAsyncTransaction *asyncdisplaykit_currentAsyncLayerTransaction;
- (void)asyncdisplaykit_asyncTransactionContainerWillBeginTransaction:(_ASAsyncTransaction *)transaction; - (void)asyncdisplaykit_asyncTransactionContainerWillBeginTransaction:(_ASAsyncTransaction *)transaction;
- (void)asyncdisplaykit_asyncTransactionContainerDidCompleteTransaction:(_ASAsyncTransaction *)transaction; - (void)asyncdisplaykit_asyncTransactionContainerDidCompleteTransaction:(_ASAsyncTransaction *)transaction;

View File

@@ -59,13 +59,13 @@ typedef NS_ENUM(NSUInteger, ASAsyncTransactionContainerState) {
did not already exist. This method will always return an open, uncommitted transaction. did not already exist. This method will always return an open, uncommitted transaction.
@desc asyncdisplaykit_isAsyncTransactionContainer does not need to be YES for this to return a transaction. @desc asyncdisplaykit_isAsyncTransactionContainer does not need to be YES for this to return a transaction.
*/ */
@property (nonatomic, readonly, retain) _ASAsyncTransaction *asyncdisplaykit_asyncTransaction; @property (nonatomic, readonly, strong) _ASAsyncTransaction *asyncdisplaykit_asyncTransaction;
/** /**
@summary Goes up the superlayer chain until it finds the first layer with asyncdisplaykit_isAsyncTransactionContainer=YES (including the receiver) and returns it. @summary Goes up the superlayer chain until it finds the first layer with asyncdisplaykit_isAsyncTransactionContainer=YES (including the receiver) and returns it.
Returns nil if no parent container is found. Returns nil if no parent container is found.
*/ */
@property (nonatomic, readonly, retain) CALayer *asyncdisplaykit_parentTransactionContainer; @property (nonatomic, readonly, strong) CALayer *asyncdisplaykit_parentTransactionContainer;
@end @end
@interface UIView (ASDisplayNodeAsyncTransactionContainer) <ASDisplayNodeAsyncTransactionContainer> @interface UIView (ASDisplayNodeAsyncTransactionContainer) <ASDisplayNodeAsyncTransactionContainer>

View File

@@ -20,20 +20,20 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) CGPoint position; @property (nonatomic, assign) CGPoint position;
@property (nonatomic, assign) CGFloat zPosition; @property (nonatomic, assign) CGFloat zPosition;
@property (nonatomic, assign) CGPoint anchorPoint; @property (nonatomic, assign) CGPoint anchorPoint;
@property (nullable, nonatomic, retain) id contents; @property (nullable, nonatomic, strong) id contents;
@property (nonatomic, assign) CGFloat cornerRadius; @property (nonatomic, assign) CGFloat cornerRadius;
@property (nonatomic, assign) CGFloat contentsScale; @property (nonatomic, assign) CGFloat contentsScale;
@property (nonatomic, assign) CATransform3D transform; @property (nonatomic, assign) CATransform3D transform;
@property (nonatomic, assign) CATransform3D sublayerTransform; @property (nonatomic, assign) CATransform3D sublayerTransform;
@property (nonatomic, assign) BOOL needsDisplayOnBoundsChange; @property (nonatomic, assign) BOOL needsDisplayOnBoundsChange;
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef shadowColor; @property (nonatomic, strong) __attribute__((NSObject)) CGColorRef shadowColor;
@property (nonatomic, assign) CGFloat shadowOpacity; @property (nonatomic, assign) CGFloat shadowOpacity;
@property (nonatomic, assign) CGSize shadowOffset; @property (nonatomic, assign) CGSize shadowOffset;
@property (nonatomic, assign) CGFloat shadowRadius; @property (nonatomic, assign) CGFloat shadowRadius;
@property (nonatomic, assign) CGFloat borderWidth; @property (nonatomic, assign) CGFloat borderWidth;
@property (nonatomic, assign, getter = isOpaque) BOOL opaque; @property (nonatomic, assign, getter = isOpaque) BOOL opaque;
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef borderColor; @property (nonatomic, strong) __attribute__((NSObject)) CGColorRef borderColor;
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef backgroundColor; @property (nonatomic, strong) __attribute__((NSObject)) CGColorRef backgroundColor;
@property (nonatomic, assign) BOOL allowsEdgeAntialiasing; @property (nonatomic, assign) BOOL allowsEdgeAntialiasing;
@property (nonatomic, assign) unsigned int edgeAntialiasingMask; @property (nonatomic, assign) unsigned int edgeAntialiasingMask;
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, getter=isHidden) BOOL hidden; @property (nonatomic, getter=isHidden) BOOL hidden;
@property (nonatomic, assign) BOOL autoresizesSubviews; @property (nonatomic, assign) BOOL autoresizesSubviews;
@property (nonatomic, assign) UIViewAutoresizing autoresizingMask; @property (nonatomic, assign) UIViewAutoresizing autoresizingMask;
@property (nonatomic, retain, null_resettable) UIColor *tintColor; @property (nonatomic, strong, null_resettable) UIColor *tintColor;
@property (nonatomic, assign) CGFloat alpha; @property (nonatomic, assign) CGFloat alpha;
@property (nonatomic, assign) CGRect bounds; @property (nonatomic, assign) CGRect bounds;
@property (nonatomic, assign) CGRect frame; // Only for use with nodes wrapping synchronous views @property (nonatomic, assign) CGRect frame; // Only for use with nodes wrapping synchronous views
@@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (atomic, copy) NSString *accessibilityValue; @property (atomic, copy) NSString *accessibilityValue;
@property (atomic, assign) UIAccessibilityTraits accessibilityTraits; @property (atomic, assign) UIAccessibilityTraits accessibilityTraits;
@property (atomic, assign) CGRect accessibilityFrame; @property (atomic, assign) CGRect accessibilityFrame;
@property (atomic, retain) NSString *accessibilityLanguage; @property (atomic, strong) NSString *accessibilityLanguage;
@property (atomic, assign) BOOL accessibilityElementsHidden; @property (atomic, assign) BOOL accessibilityElementsHidden;
@property (atomic, assign) BOOL accessibilityViewIsModal; @property (atomic, assign) BOOL accessibilityViewIsModal;
@property (atomic, assign) BOOL shouldGroupAccessibilityChildren; @property (atomic, assign) BOOL shouldGroupAccessibilityChildren;

View File

@@ -23,7 +23,7 @@
// Keep the node alive while its view is active. If you create a view, add its layer to a layer hierarchy, then release // Keep the node alive while its view is active. If you create a view, add its layer to a layer hierarchy, then release
// the view, the layer retains the view to prevent a crash. This replicates this behaviour for the node abstraction. // the view, the layer retains the view to prevent a crash. This replicates this behaviour for the node abstraction.
@property (nonatomic, retain, readwrite) ASDisplayNode *keepalive_node; @property (nonatomic, strong, readwrite) ASDisplayNode *keepalive_node;
@end @end
@implementation _ASDisplayView @implementation _ASDisplayView

View File

@@ -100,7 +100,7 @@ struct _Range {
{ {
CGFloat newMin = MAX(min, other.min); CGFloat newMin = MAX(min, other.min);
CGFloat newMax = MIN(max, other.max); CGFloat newMax = MIN(max, other.max);
if (!(newMin > newMax)) { if (newMin <= newMax) {
return {newMin, newMax}; return {newMin, newMax};
} else { } else {
// No intersection. If we're before the other range, return our max; otherwise our min. // No intersection. If we're before the other range, return our max; otherwise our min.

View File

@@ -140,7 +140,7 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
+ (void)scheduleNodeForRecursiveDisplay:(ASDisplayNode *)node; + (void)scheduleNodeForRecursiveDisplay:(ASDisplayNode *)node;
// The _ASDisplayLayer backing the node, if any. // The _ASDisplayLayer backing the node, if any.
@property (nonatomic, readonly, retain) _ASDisplayLayer *asyncLayer; @property (nonatomic, readonly, strong) _ASDisplayLayer *asyncLayer;
// Bitmask to check which methods an object overrides. // Bitmask to check which methods an object overrides.
@property (nonatomic, assign, readonly) ASDisplayNodeMethodOverrides methodOverrides; @property (nonatomic, assign, readonly) ASDisplayNodeMethodOverrides methodOverrides;

View File

@@ -24,7 +24,7 @@ extern NSString *const ASTextKitEntityAttributeName;
static inline BOOL _objectsEqual(id<NSObject> obj1, id<NSObject> obj2) static inline BOOL _objectsEqual(id<NSObject> obj1, id<NSObject> obj2)
{ {
return obj1 == obj2 ? YES : [obj1 isEqual:obj2]; return obj1 == obj2 || [obj1 isEqual:obj2];
} }
/** /**

View File

@@ -16,7 +16,5 @@
*/ */
ASDISPLAYNODE_INLINE BOOL ASObjectIsEqual(id<NSObject> obj, id<NSObject> otherObj) ASDISPLAYNODE_INLINE BOOL ASObjectIsEqual(id<NSObject> obj, id<NSObject> otherObj)
{ {
if (obj == otherObj) return obj == otherObj || [obj isEqual:otherObj];
return YES;
return [obj isEqual:otherObj];
} }