Skip to content

Commit

Permalink
Revert "Route setDelegate: to setAsyncDelegate: (#3007)" (#3023)
Browse files Browse the repository at this point in the history
This reverts commit 5c8818d.
  • Loading branch information
Adlai Holler authored Feb 13, 2017
1 parent ec59c31 commit 0badff6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 0 additions & 3 deletions AsyncDisplayKit/ASCollectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ NS_ASSUME_NONNULL_BEGIN

@interface ASCollectionView (Deprecated)

@property (nonatomic, weak) id<UICollectionViewDelegate> delegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode.delegate instead. If you REALLY want to use this, cast to a UICollectionView but don't rely on the return value.");
@property (nonatomic, weak) id<UICollectionViewDataSource> dataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode.dataSource instead. If you REALLY want to use this, cast to a UICollectionView but don't rely on the return value.");

/**
* The object that acts as the asynchronous delegate of the collection view
*
Expand Down
6 changes: 2 additions & 4 deletions AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,8 @@ - (void)setDataSource:(id<UICollectionViewDataSource>)dataSource

- (void)setDelegate:(id<UICollectionViewDelegate>)delegate
{
// The compiler will prevent users from calling this,
// but we will automatically route to @c asyncDelegate
// to support interop with frameworks like TLYShyNavBar.
self.asyncDelegate = (id<ASCollectionDelegate>)delegate;
// Our UIScrollView superclass sets its delegate to nil on dealloc. Only assert if we get a non-nil value here. We also allow this when we're doing interop.
ASDisplayNodeAssert(_asyncDelegateFlags.interop || delegate == nil, @"ASCollectionView uses asyncDelegate, not UICollectionView's delegate property.");
}

- (void)proxyTargetHasDeallocated:(ASDelegateProxy *)proxy
Expand Down
3 changes: 0 additions & 3 deletions AsyncDisplayKit/ASTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ NS_ASSUME_NONNULL_BEGIN

@interface ASTableView (Deprecated)

@property (nonatomic, weak) id<UITableViewDelegate> delegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode.delegate instead. If you REALLY want to use this, cast to UITableView but don't rely on the return value.");
@property (nonatomic, weak) id<UITableViewDataSource> dataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode.dataSource instead. If you REALLY want to use this, cast to UITableView but don't rely on the return value.");

@property (nonatomic, weak) id<ASTableDelegate> asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode's .delegate property instead.");
@property (nonatomic, weak) id<ASTableDataSource> asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode .dataSource property instead.");

Expand Down
8 changes: 3 additions & 5 deletions AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ - (void)setDataSource:(id<UITableViewDataSource>)dataSource

- (void)setDelegate:(id<UITableViewDelegate>)delegate
{
// The compiler will prevent users from calling this,
// but we will automatically route to @c asyncDelegate
// to support interop with frameworks like TLYShyNavBar.
self.asyncDelegate = (id<ASTableDelegate>)delegate;
// Our UIScrollView superclass sets its delegate to nil on dealloc. Only assert if we get a non-nil value here.
ASDisplayNodeAssert(delegate == nil, @"ASTableView uses asyncDelegate, not UITableView's delegate property.");
}

- (id<ASTableDataSource>)asyncDataSource
Expand All @@ -357,7 +355,7 @@ - (void)setAsyncDataSource:(id<ASTableDataSource>)asyncDataSource
// the (common) case of nilling the asyncDataSource in the ViewController's dealloc. In this case our _asyncDataSource
// will return as nil (ARC magic) even though the _proxyDataSource still exists. It's really important to hold a strong
// reference to the old dataSource in this case because calls to ASTableViewProxy will start failing and cause crashes.
NS_VALID_UNTIL_END_OF_SCOPE id oldDataSource = super.dataSource;
NS_VALID_UNTIL_END_OF_SCOPE id oldDataSource = self.dataSource;

if (asyncDataSource == nil) {
_asyncDataSource = nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ class MosaicCollectionViewLayoutInspector: NSObject, ASCollectionViewLayoutInspe
return ASSizeRange.init(min: CGSize.zero, max: layout._headerSizeForSection(section: atIndexPath.section))
}

/**
* Asks the inspector for the number of supplementary sections in the collection view for the given kind.
*/
func collectionView(_ collectionView: ASCollectionView, numberOfSectionsForSupplementaryNodeOfKind kind: String) -> UInt {
if (kind == UICollectionElementKindSectionHeader) {
return UInt((collectionView.dataSource?.numberOfSections!(in: collectionView))!)
} else {
return 0
}
}

/**
* Asks the inspector for the number of supplementary views for the given kind in the specified section.
*/
Expand All @@ -240,6 +251,6 @@ class MosaicCollectionViewLayoutInspector: NSObject, ASCollectionViewLayoutInspe
}

func scrollableDirections() -> ASScrollDirection {
return ASScrollDirectionVerticalDirections
return ASScrollDirectionVerticalDirections;
}
}

0 comments on commit 0badff6

Please sign in to comment.