Handle cases where the delegate is already an IGListAdapter

Summary:
I was assuming the delegate would always be an IGListAdapterProxy, but this only happens if the client sets either the `collectionViewDelegate` or `scrollViewDelegate` properties on IGListAdapter. Otherwise the delegate will just be the IGListAdapter. Change the debug code to handle this case.

We were starting to see some debug logs roll in with the delegate class listed as IGListAdapter. Hopefully this will return the correct class now.

Differential Revision: D31690438

fbshipit-source-id: bf6dde57756fee4fe617944d45e152cae734b4f1
This commit is contained in:
Brandon Kieft 2021-10-19 08:48:07 -07:00 committed by Facebook GitHub Bot
parent 0f9d8b8db2
commit b367f7ceb2

View file

@ -462,16 +462,18 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
- (NSString *)_classNameForDelegate:(id<UICollectionViewDelegateFlowLayout>)delegate sectionIndex:(NSInteger)section {
NSString *const delegateClassString = NSStringFromClass(delegate.class);
if ([delegateClassString isEqualToString:@"IGListAdapterProxy"] == NO) {
const BOOL isListAdapter = [delegateClassString isEqualToString:@"IGListAdapter"];
const BOOL isListAdapterProxy = [delegateClassString isEqualToString:@"IGListAdapterProxy"];
if (isListAdapter == NO && isListAdapterProxy == NO) {
return delegateClassString;
}
id forwardingObject = [(id)delegate forwardingTargetForSelector:@selector(collectionView:layout:insetForSectionAtIndex:)];
const id forwardingObject = (isListAdapterProxy ? [(id)delegate forwardingTargetForSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] : delegate);
if ([forwardingObject isKindOfClass:IGListAdapter.class] == NO) {
return NSStringFromClass([forwardingObject class]);
}
id sectionController = [forwardingObject sectionControllerForSection:section];
const id sectionController = [forwardingObject sectionControllerForSection:section];
return NSStringFromClass([sectionController class]);
}