Skip to content

Commit 8c9a562

Browse files
authored
Merge pull request #80 from greenius/xcode12
Fix problem of assigned controlView being optimised away in XCode 12 …
2 parents eab1a55 + a443008 commit 8c9a562

6 files changed

Lines changed: 28 additions & 32 deletions

File tree

MMTabBarView/MMTabBarView.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@
839839
developmentRegion = English;
840840
hasScannedForEncodings = 0;
841841
knownRegions = (
842+
English,
842843
en,
843844
);
844845
mainGroup = 06DB239A1609F5820071BDA0;

MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
1818

1919
/**
2020
* The control view
21-
*
22-
* TODO: fix, rename "attachedTabBarButton"
2321
*/
24-
#pragma clang diagnostic push
25-
#pragma clang diagnostic ignored "-Wincompatible-property-type"
26-
@property (assign) MMAttachedTabBarButton *controlView;
27-
#pragma clang diagnostic pop
22+
@property (nullable, weak) MMAttachedTabBarButton *attachedTabBarButton;
2823

2924
@end
3025

MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ - (instancetype)init {
2424
#pragma mark -
2525
#pragma mark Properties
2626

27-
- (MMAttachedTabBarButton *)controlView {
28-
return (MMAttachedTabBarButton *)[super controlView];
27+
- (nullable MMAttachedTabBarButton *)controlView {
28+
// return (MMAttachedTabBarButton *)[super controlView];
29+
return _attachedTabBarButton;
2930
}
3031

31-
- (void)setControlView:(MMAttachedTabBarButton *)aView {
32-
[super setControlView:aView];
32+
- (void) setControlView:(nullable NSView *)aView
33+
{
34+
[super setControlView:aView];
35+
_attachedTabBarButton = (MMAttachedTabBarButton*)aView;
3336
}
3437

3538
#pragma mark -

MMTabBarView/MMTabBarView/MMTabBarButtonCell.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,13 @@ NS_ASSUME_NONNULL_BEGIN
3636

3737
/**
3838
* The control view
39-
*
40-
* TODO: fix, rename "tabBarButton"
4139
*/
42-
#pragma clang diagnostic push
43-
#pragma clang diagnostic ignored "-Wincompatible-property-type"
44-
@property (assign) MMTabBarButton *controlView;
45-
#pragma clang diagnostic pop
40+
@property (nullable, weak) MMTabBarButton *tabBarButton;
4641

4742
/**
4843
* Tab bar view the tab bar button belongs to
4944
*/
50-
@property (readonly) MMTabBarView *tabBarView;
45+
@property (nullable, readonly) MMTabBarView *tabBarView;
5146

5247
#pragma mark Update images
5348

@@ -118,14 +113,14 @@ NS_ASSUME_NONNULL_BEGIN
118113
/**
119114
* Get progress indicator
120115
*/
121-
@property (readonly) MMProgressIndicator *indicator;
116+
@property (nullable, readonly) MMProgressIndicator *indicator;
122117

123118
#pragma mark Close Button Support
124119

125120
/**
126121
* The close button
127122
*/
128-
@property (readonly) MMRolloverButton *closeButton;
123+
@property (nullable, readonly) MMRolloverButton *closeButton;
129124

130125
/**
131126
* Check if receiver should display close button

MMTabBarView/MMTabBarView/MMTabBarButtonCell.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ - (instancetype)init {
5353
return self;
5454
}
5555

56-
- (MMTabBarButton *)controlView {
57-
return (MMTabBarButton *)[super controlView];
56+
- (nullable MMTabBarButton *)controlView {
57+
// return (MMTabBarButton *)[super controlView];
58+
return _tabBarButton;
5859
}
5960

60-
- (void)setControlView:(MMTabBarButton *)aView {
61-
[super setControlView:aView];
61+
- (void)setControlView:(nullable NSView *)aView {
62+
_tabBarButton = (MMTabBarButton*) aView;
63+
[super setControlView:aView];
6264
}
6365

64-
- (MMTabBarView *)tabBarView {
65-
return self.controlView.tabBarView;
66+
- (nullable MMTabBarView *)tabBarView {
67+
return _tabBarButton.tabBarView;
6668
}
6769

6870
- (void)calcDrawInfo:(NSRect)aRect {
@@ -183,15 +185,15 @@ - (void)setState:(NSInteger)value {
183185
#pragma mark -
184186
#pragma mark Progress Indicator Support
185187

186-
- (MMProgressIndicator *)indicator {
187-
return self.controlView.indicator;
188+
- (nullable MMProgressIndicator *)indicator {
189+
return self.tabBarButton.indicator;
188190
}
189191

190192
#pragma mark -
191193
#pragma mark Close Button Support
192194

193-
- (MMRolloverButton *)closeButton {
194-
return self.controlView.closeButton;
195+
- (nullable MMRolloverButton *)closeButton {
196+
return self.tabBarButton.closeButton;
195197
}
196198

197199
- (NSImage *)closeButtonImageOfType:(MMCloseButtonImageType)type {
@@ -599,7 +601,7 @@ - (NSImage *)_closeButtonImageOfType:(MMCloseButtonImageType)type {
599601
- (void)_updateCloseButton {
600602

601603
MMTabBarView *tabBarView = self.tabBarView;
602-
MMTabBarButton *button = self.controlView;
604+
MMTabBarButton *button = self.tabBarButton;
603605
MMRolloverButton *closeButton = button.closeButton;
604606

605607
[self _updateCloseButtonImages];
@@ -630,7 +632,7 @@ - (void)_updateCloseButton {
630632
- (void)_updateIndicator {
631633

632634
MMTabBarView *tabBarView = self.tabBarView;
633-
MMTabBarButton *button = self.controlView;
635+
MMTabBarButton *button = self.tabBarButton;
634636
MMProgressIndicator *indicator = button.indicator;
635637

636638
// adjust visibility and position of process indicator

MMTabBarView/MMTabBarView/Styles/Mojave Tab Style/MMMojaveTabStyle.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)ce
161161

162162
// Figure out correct text color
163163

164-
if ( cell.controlView.state == NSOnState )
164+
if ( cell.tabBarButton.state == NSOnState )
165165
{
166166
textColor = [self colorForPart:MMMtabSelectedFont ofTabBarView:cell.tabBarView];
167167
}

0 commit comments

Comments
 (0)