Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NS_SWIFT_UI_ACTOR to methods always called on main #2121

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/ASCellNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
* The backing view controller, or @c nil if the node wasn't initialized with backing view controller
* @note This property must be accessed on the main thread.
*/
@property (nullable, nonatomic, readonly) UIViewController *viewController;
@property (nullable, nonatomic, readonly) UIViewController *viewController NS_SWIFT_UI_ACTOR;


/**
Expand Down
4 changes: 2 additions & 2 deletions Source/ASCollectionNode+Beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* The elements that are currently displayed. The "UIKit index space". Must be accessed on main thread.
*/
@property (nonatomic, readonly) ASElementMap *visibleElements;
@property (nonatomic, readonly) ASElementMap *visibleElements NS_SWIFT_UI_ACTOR;

@property (nullable, readonly) id<ASCollectionLayoutDelegate> layoutDelegate;

Expand Down Expand Up @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* When isSynchronized == YES, the block is run block immediately (before the method returns).
*/
- (void)onDidFinishSynchronizing:(void (^)(void))didFinishSynchronizing;
- (void)onDidFinishSynchronizing:(NS_SWIFT_UI_ACTOR void (^)(void))didFinishSynchronizing;

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(nullable id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator;

Expand Down
40 changes: 20 additions & 20 deletions Source/ASCollectionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* This method must be called on the main thread.
*/
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated;
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated NS_SWIFT_UI_ACTOR;

/**
* Determines collection node's current scroll direction. Supports 2-axis collection nodes.
Expand Down Expand Up @@ -266,7 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
*/
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion;
- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion NS_SWIFT_UI_ACTOR;

/**
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
Expand All @@ -277,7 +277,7 @@ NS_ASSUME_NONNULL_BEGIN
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
*/
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion;
- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion NS_SWIFT_UI_ACTOR;
rcancro marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns YES if the ASCollectionNode is still processing changes from performBatchUpdates:.
Expand Down Expand Up @@ -306,7 +306,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Calling -waitUntilAllUpdatesAreProcessed is one way to flush any pending update completion blocks.
*/
- (void)onDidFinishProcessingUpdates:(void (^)(void))didFinishProcessingUpdates;
- (void)onDidFinishProcessingUpdates:(NS_SWIFT_UI_ACTOR void (^)(void))didFinishProcessingUpdates;

/**
* Blocks execution of the main thread until all section and item updates are committed to the view. This method must be called from the main thread.
Expand All @@ -321,7 +321,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)insertSections:(NSIndexSet *)sections;
- (void)insertSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR;

/**
* Deletes one or more sections.
Expand All @@ -331,7 +331,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)deleteSections:(NSIndexSet *)sections;
- (void)deleteSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR;

/**
* Reloads the specified sections.
Expand All @@ -341,7 +341,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)reloadSections:(NSIndexSet *)sections;
- (void)reloadSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR;

/**
* Moves a section to a new location.
Expand All @@ -353,7 +353,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection NS_SWIFT_UI_ACTOR;

/**
* Inserts items at the locations identified by an array of index paths.
Expand All @@ -363,7 +363,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)insertItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
- (void)insertItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_SWIFT_UI_ACTOR;

/**
* Deletes the items specified by an array of index paths.
Expand All @@ -373,7 +373,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)deleteItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
- (void)deleteItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_SWIFT_UI_ACTOR;

/**
* Reloads the specified items.
Expand All @@ -383,7 +383,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_SWIFT_UI_ACTOR;

/**
* Moves the item at a specified location to a destination location.
Expand All @@ -395,7 +395,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This method must be called from the main thread. The data source must be updated to reflect the changes
* before this method is called.
*/
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath NS_SWIFT_UI_ACTOR;

/**
* Reload everything from scratch, destroying the working range and all cached nodes.
Expand All @@ -404,7 +404,7 @@ NS_ASSUME_NONNULL_BEGIN
* the main thread.
* @warning This method is substantially more expensive than UICollectionView's version.
*/
- (void)reloadDataWithCompletion:(nullable void (^)(void))completion;
- (void)reloadDataWithCompletion:(nullable NS_SWIFT_UI_ACTOR void (^)(void))completion;


/**
Expand Down Expand Up @@ -441,7 +441,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @discussion This method must be called from the main thread.
*/
- (void)selectItemAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UICollectionViewScrollPosition)scrollPosition;
- (void)selectItemAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UICollectionViewScrollPosition)scrollPosition NS_SWIFT_UI_ACTOR;

/**
* Deselects the item at the specified index.
Expand All @@ -454,7 +454,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @discussion This method must be called from the main thread.
*/
- (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
- (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated NS_SWIFT_UI_ACTOR;

#pragma mark - Querying Data

Expand All @@ -477,7 +477,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return an array containing the nodes being displayed on screen. This must be called on the main thread.
*/
@property (nonatomic, readonly) NSArray<__kindof ASCellNode *> *visibleNodes;
@property (nonatomic, readonly) NSArray<__kindof ASCellNode *> *visibleNodes NS_SWIFT_UI_ACTOR;

/**
* Retrieves the node for the item at the given index path.
Expand Down Expand Up @@ -513,7 +513,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return an array containing the index paths of all visible items. This must be called on the main thread.
*/
@property (nonatomic, readonly) NSArray<NSIndexPath *> *indexPathsForVisibleItems;
@property (nonatomic, readonly) NSArray<NSIndexPath *> *indexPathsForVisibleItems NS_SWIFT_UI_ACTOR;

/**
* Retrieve the index path of the item at the given point.
Expand All @@ -522,7 +522,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return The indexPath for the item at the given point. This must be called on the main thread.
*/
- (nullable NSIndexPath *)indexPathForItemAtPoint:(CGPoint)point AS_WARN_UNUSED_RESULT;
- (nullable NSIndexPath *)indexPathForItemAtPoint:(CGPoint)point AS_WARN_UNUSED_RESULT NS_SWIFT_UI_ACTOR;

/**
* Retrieve the cell at the given index path.
Expand All @@ -531,7 +531,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return The cell for the given index path. This must be called on the main thread.
*/
- (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPath;
- (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPath NS_SWIFT_UI_ACTOR;

/**
* Retrieves the context object for the given section, as provided by the data source in
Expand Down Expand Up @@ -610,7 +610,7 @@ NS_ASSUME_NONNULL_BEGIN
* not implement reuse (it will be called once per item). Unlike UICollectionView's version,
* this method is not called when the item is about to display.
*/
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath NS_SWIFT_UI_ACTOR;

/**
* Asks the data source to provide a node-block to display for the given supplementary element in the collection view.
Expand Down
2 changes: 1 addition & 1 deletion Source/ASCollectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return The context object, or @c nil if no context was provided.
*/
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT;
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT NS_SWIFT_UI_ACTOR;

@end

Expand Down
2 changes: 1 addition & 1 deletion Source/ASDisplayNode+Convenience.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
* @warning This property may only be accessed on the main thread. This property may
* be @c nil until the node's view is actually hosted in the view hierarchy.
*/
@property (nonatomic, nullable, readonly) __kindof UIViewController *closestViewController;
@property (nonatomic, nullable, readonly) __kindof UIViewController *closestViewController NS_SWIFT_UI_ACTOR;

@end

Expand Down
26 changes: 13 additions & 13 deletions Source/ASDisplayNode+InterfaceState.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,63 +46,63 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState)
* @discussion Subclasses may use this to monitor when they become visible, should free cached data, and much more.
* @see ASInterfaceState
*/
- (void)interfaceStateDidChange:(ASInterfaceState)newState fromState:(ASInterfaceState)oldState;
- (void)interfaceStateDidChange:(ASInterfaceState)newState fromState:(ASInterfaceState)oldState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the node becomes visible.
* @discussion Subclasses may use this to monitor when they become visible.
* @note This method is guaranteed to be called on main.
*/
- (void)didEnterVisibleState;
- (void)didEnterVisibleState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the node is no longer visible.
* @discussion Subclasses may use this to monitor when they are no longer visible.
* @note This method is guaranteed to be called on main.
*/
- (void)didExitVisibleState;
- (void)didExitVisibleState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the the node has entered the display state.
* @discussion Subclasses may use this to monitor when a node should be rendering its content.
* @note This method is guaranteed to be called on main.
*/
- (void)didEnterDisplayState;
- (void)didEnterDisplayState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the the node has exited the display state.
* @discussion Subclasses may use this to monitor when a node should no longer be rendering its content.
* @note This method is guaranteed to be called on main.
*/
- (void)didExitDisplayState;
- (void)didExitDisplayState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the the node has entered the preload state.
* @discussion Subclasses may use this to monitor data for a node should be preloaded, either from a local or remote source.
* @note This method is guaranteed to be called on main.
*/
- (void)didEnterPreloadState;
- (void)didEnterPreloadState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called whenever the the node has exited the preload state.
* @discussion Subclasses may use this to monitor whether preloading data for a node should be canceled.
* @note This method is guaranteed to be called on main.
*/
- (void)didExitPreloadState;
- (void)didExitPreloadState NS_SWIFT_UI_ACTOR;

/**
* @abstract Called when the node has completed applying the layout.
* @discussion Can be used for operations that are performed after layout has completed.
* @note This method is guaranteed to be called on main.
*/
- (void)nodeDidLayout;
- (void)nodeDidLayout NS_SWIFT_UI_ACTOR;

/**
* @abstract Called when the node loads.
* @discussion Can be used for operations that are performed after the node's view is available.
* @note This method is guaranteed to be called on main.
*/
- (void)nodeDidLoad;
- (void)nodeDidLoad NS_SWIFT_UI_ACTOR;

/**
* @abstract Indicates that the receiver and all subnodes have finished displaying.
Expand All @@ -114,7 +114,7 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState)
* the progressImage block.
* @note This method is guaranteed to be called on main.
*/
- (void)hierarchyDisplayDidFinish;
- (void)hierarchyDisplayDidFinish NS_SWIFT_UI_ACTOR;

@optional
/**
Expand All @@ -125,7 +125,7 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState)
* to attempt to ascend the node tree when handling this, as the root node is locked when this is
* called.
*/
- (void)nodeWillCalculateLayout:(ASSizeRange)constrainedSize;
- (void)nodeWillCalculateLayout:(ASSizeRange)constrainedSize NS_SWIFT_UI_ACTOR;

/**
* @abstract Called when the node's layer is about to enter the hierarchy.
Expand All @@ -134,7 +134,7 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState)
* re-parented multiple times, and each time will trigger this call.
* @note This method is guaranteed to be called on main.
*/
- (void)didEnterHierarchy;
- (void)didEnterHierarchy NS_SWIFT_UI_ACTOR;

/**
* @abstract Called when the node's layer has exited the hierarchy.
Expand All @@ -143,6 +143,6 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState)
* re-parented multiple times, and each time will trigger this call.
* @note This method is guaranteed to be called on main.
*/
- (void)didExitHierarchy;
- (void)didExitHierarchy NS_SWIFT_UI_ACTOR;

@end
10 changes: 5 additions & 5 deletions Source/ASDisplayNode+Subclasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion This is the best time to add gesture recognizers to the view.
*/
AS_CATEGORY_IMPLEMENTABLE
- (void)didLoad ASDISPLAYNODE_REQUIRES_SUPER;
- (void)didLoad ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR;

/**
* An empty method that you can implement in a category to add global
Expand All @@ -95,7 +95,7 @@ AS_CATEGORY_IMPLEMENTABLE
*
* @discussion Subclasses override this method to layout all subnodes or subviews.
*/
- (void)layout ASDISPLAYNODE_REQUIRES_SUPER;
- (void)layout ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR;

/**
* @abstract Called on the main thread by the view's -layoutSubviews, after -layout.
Expand All @@ -104,7 +104,7 @@ AS_CATEGORY_IMPLEMENTABLE
* out.
*/
AS_CATEGORY_IMPLEMENTABLE
- (void)layoutDidFinish ASDISPLAYNODE_REQUIRES_SUPER;
- (void)layoutDidFinish ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR;

/**
* @abstract Called on a background thread if !isNodeLoaded - called on the main thread if isNodeLoaded.
Expand Down Expand Up @@ -255,7 +255,7 @@ AS_CATEGORY_IMPLEMENTABLE
*
* @note Called on the main thread only
*/
- (nullable id<NSObject>)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer;
- (nullable id<NSObject>)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer NS_SWIFT_UI_ACTOR;

/**
* @abstract Indicates that the receiver is about to display.
Expand Down Expand Up @@ -317,7 +317,7 @@ AS_CATEGORY_IMPLEMENTABLE
* @discussion Called by -recursivelyClearContents. Always called on main thread. Base class implements self.contents = nil, clearing any backing
* store, for asynchronous regeneration when needed.
*/
- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER;
- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR;

/**
* @abstract Indicates that the receiver is about to display its subnodes. This method is not called if there are no
Expand Down
Loading