Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 88bfd3e

Browse files
committed
Merge pull request #995 from facebook/pr/664
[Refactoring] Adopt Objective-C Nullability, Lightweight Generics Annotations
2 parents 406bcfa + 7b0c82b commit 88bfd3e

94 files changed

Lines changed: 519 additions & 262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode7
2+
osx_image: xcode7.2
33
before_install:
44
- brew update
55
- brew reinstall xctool

AsyncDisplayKit-Prefix.gcda

0 Bytes
Binary file not shown.

AsyncDisplayKit/ASButtonNode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* of patent rights can be found in the PATENTS file in the same directory.
77
*/
88

9-
#import <AsyncDisplayKit/AsyncDisplayKit.h>
9+
#import <AsyncDisplayKit/ASTextNode.h>
10+
#import <AsyncDisplayKit/ASImageNode.h>
1011

1112
typedef enum : NSUInteger {
1213
ASButtonStateNormal,

AsyncDisplayKit/ASButtonNode.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
*/
88

99
#import "ASButtonNode.h"
10-
11-
#import <AsyncDisplayKit/ASThread.h>
10+
#import "ASStackLayoutSpec.h"
11+
#import "ASThread.h"
12+
#import "ASDisplayNode+Subclasses.h"
1213

1314
@interface ASButtonNode ()
1415
{

AsyncDisplayKit/ASCellNode.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import <AsyncDisplayKit/ASDisplayNode.h>
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
@class ASCellNode;
1214

1315
typedef NSUInteger ASCellNodeAnimation;
@@ -77,10 +79,10 @@ typedef NSUInteger ASCellNodeAnimation;
7779
* ASCellNode must forward touch events in order for UITableView and UICollectionView tap handling to work. Overriding
7880
* these methods (e.g. for highlighting) requires the super method be called.
7981
*/
80-
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
81-
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
82-
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
83-
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
82+
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
83+
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
84+
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
85+
- (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER;
8486

8587
/**
8688
* Marks the node as needing layout. Convenience for use whether the view / layer is loaded or not.
@@ -119,3 +121,5 @@ typedef NSUInteger ASCellNodeAnimation;
119121
@property (nonatomic, copy) NSString *text;
120122

121123
@end
124+
125+
NS_ASSUME_NONNULL_END

AsyncDisplayKit/ASCellNode.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ - (instancetype)init
167167
{
168168
if (!(self = [super init]))
169169
return nil;
170-
170+
171+
_text = @"";
171172
_textNode = [[ASTextNode alloc] init];
172173
[self addSubnode:_textNode];
173174

AsyncDisplayKit/ASCollectionNode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import <AsyncDisplayKit/ASCollectionView.h>
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
/**
1214
* ASCollectionNode is a node based class that wraps an ASCollectionView. It can be used
1315
* as a subnode of another node, and provide room for many (great) features and improvements later on.
@@ -67,3 +69,5 @@
6769
- (void)reloadDataImmediately;
6870

6971
@end
72+
73+
NS_ASSUME_NONNULL_END

AsyncDisplayKit/ASCollectionNode.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ @implementation ASCollectionNode
3030
- (instancetype)init
3131
{
3232
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
33-
self = [self initWithCollectionViewLayout:nil]; // Will throw an exception for lacking a UICV Layout.
33+
UICollectionViewLayout *nilLayout = nil;
34+
self = [self initWithCollectionViewLayout:nilLayout]; // Will throw an exception for lacking a UICV Layout.
3435
return nil;
3536
}
3637

AsyncDisplayKit/ASCollectionView.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
@protocol ASCollectionDelegate;
2020
@protocol ASCollectionViewLayoutInspecting;
2121

22+
NS_ASSUME_NONNULL_BEGIN
23+
2224
/**
2325
* Node-based collection view.
2426
*
@@ -87,7 +89,7 @@
8789
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
8890
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
8991
*/
90-
- (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completion:(void (^)(BOOL))completion;
92+
- (void)performBatchAnimated:(BOOL)animated updates:(void (^ _Nullable)())updates completion:(void (^ _Nullable)(BOOL))completion;
9193

9294
/**
9395
* Perform a batch of updates asynchronously. This method must be called from the main thread.
@@ -98,7 +100,7 @@
98100
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
99101
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
100102
*/
101-
- (void)performBatchUpdates:(void (^)())updates completion:(void (^)(BOOL))completion;
103+
- (void)performBatchUpdates:(void (^ _Nullable)())updates completion:(void (^ _Nullable)(BOOL))completion;
102104

103105
/**
104106
* Reload everything from scratch, destroying the working range and all cached nodes.
@@ -107,7 +109,7 @@
107109
* the main thread.
108110
* @warning This method is substantially more expensive than UICollectionView's version.
109111
*/
110-
- (void)reloadDataWithCompletion:(void (^)())completion;
112+
- (void)reloadDataWithCompletion:(void (^ _Nullable)())completion;
111113

112114
/**
113115
* Reload everything from scratch, destroying the working range and all cached nodes.
@@ -186,7 +188,7 @@
186188
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
187189
* before this method is called.
188190
*/
189-
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths;
191+
- (void)insertItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
190192

191193
/**
192194
* Deletes the items specified by an array of index paths.
@@ -196,7 +198,7 @@
196198
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
197199
* before this method is called.
198200
*/
199-
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths;
201+
- (void)deleteItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
200202

201203
/**
202204
* Reloads the specified items.
@@ -206,7 +208,7 @@
206208
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
207209
* before this method is called.
208210
*/
209-
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths;
211+
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
210212

211213
/**
212214
* Moves the item at a specified location to a destination location.
@@ -243,7 +245,7 @@
243245
*
244246
* @returns an array containing the nodes being displayed on screen.
245247
*/
246-
- (NSArray *)visibleNodes;
248+
- (NSArray<ASCellNode *> *)visibleNodes;
247249

248250
/**
249251
* Query the sized node at `indexPath` for its calculatedSize.
@@ -354,7 +356,7 @@
354356
@optional
355357

356358
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
357-
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath*)indexPath;
359+
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
358360

359361
/**
360362
* Receive a message that the collectionView is near the end of its data set and more data should be fetched if
@@ -423,3 +425,5 @@
423425
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout asyncDataFetching:(BOOL)asyncDataFetchingEnabled ASDISPLAYNODE_DEPRECATED;
424426

425427
@end
428+
429+
NS_ASSUME_NONNULL_END

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import "ASAssert.h"
1010
#import "ASBatchFetching.h"
1111
#import "ASDelegateProxy.h"
12-
#import "ASCollectionView.h"
1312
#import "ASCollectionNode.h"
1413
#import "ASCollectionDataController.h"
1514
#import "ASCollectionViewLayoutController.h"

0 commit comments

Comments
 (0)