Fix crash

This commit is contained in:
Bryce Hackel 2024-04-03 12:19:56 -07:00
parent 572ebf3e3b
commit f7b644457f
No known key found for this signature in database
GPG key ID: F031960F08455E88

View file

@ -281,10 +281,10 @@ BOOL isAd(YTIElementRenderer *self) {
- (void)layoutSubviews { - (void)layoutSubviews {
%orig; %orig;
// Get the badge of this cell, as it is language-independent and unique // Get the badge of this cell, as it is language-independent and unique
YTIconBadgeView *badgeView = self._iconBadgeView; YTIconBadgeView *badgeView = [self valueForKey:@"_iconBadgeView"];
// First null check for badgeView // First null check for badgeView
if (!badgeView) { if (!badgeView) {
return; // Early return if badgeView is nil return;
} }
// Walk down the subviews to get to a specific view // Walk down the subviews to get to a specific view
UIView *subview = badgeView.subviews.firstObject; UIView *subview = badgeView.subviews.firstObject;
@ -293,12 +293,12 @@ BOOL isAd(YTIElementRenderer *self) {
return; return;
} }
UIImageView *imageView = subview.subviews.firstObject; UIImageView *imageView = subview.subviews.firstObject;
// Third null check for the imageView // Third null/inavlid check for the imageView
if (!imageView) { if (!imageView || ![imageView respondsToSelector:@selector(description)]) {
return; return;
} }
// Get the description of this view // Get the description of this view
NSString *description = imageView.description; NSString *description = [imageView description];
// Check if "yt_outline_youtube_logo_icon" is in the description // Check if "yt_outline_youtube_logo_icon" is in the description
if ([description containsString:@"yt_outline_youtube_logo_icon"]) { if ([description containsString:@"yt_outline_youtube_logo_icon"]) {
self.hidden = YES; // Hide the cell self.hidden = YES; // Hide the cell