-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Code refresh + SPM support #848
Changes from 12 commits
ee2528f
b32f6cb
3cea4d5
e3e76bf
e4837f4
db62b82
6feffe0
143fbe8
7ca3dda
eefffa5
86d10de
6397d87
5167bb4
d4b9f8a
127886d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,5 @@ playground.xcworkspace | |
|
||
Carthage/Build | ||
|
||
.swift-version | ||
.swift-version | ||
.swiftpm/xcode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// | ||
// FXPageControl.h | ||
// | ||
// Version 1.4 | ||
// Version 1.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this file out of the Sources folder will make it not be included in the library when installed through Cocoapods and it is also not marked as dependency. Please either revert or add FXPageControl as dependency in the podspec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a big mistake from my side! I ran a |
||
// | ||
// Created by Nick Lockwood on 07/01/2010. | ||
// Copyright 2010 Charcoal Design | ||
|
@@ -31,18 +31,12 @@ | |
// | ||
|
||
|
||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" | ||
#import <UIKit/UIKit.h> | ||
|
||
|
||
#import <Availability.h> | ||
#undef weak_delegate | ||
#if __has_feature(objc_arc_weak) | ||
#define weak_delegate weak | ||
#else | ||
#define weak_delegate unsafe_unretained | ||
#endif | ||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
|
||
extern const CGPathRef FXPageControlDotShapeCircle; | ||
|
@@ -59,7 +53,7 @@ IB_DESIGNABLE @interface FXPageControl : UIControl | |
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount; | ||
- (void)updateCurrentPageDisplay; | ||
|
||
@property (nonatomic, weak_delegate) IBOutlet id <FXPageControlDelegate> delegate; | ||
@property (nonatomic, weak) IBOutlet id <FXPageControlDelegate> delegate; | ||
|
||
@property (nonatomic, assign) IBInspectable NSInteger currentPage; | ||
@property (nonatomic, assign) IBInspectable NSInteger numberOfPages; | ||
|
@@ -68,21 +62,25 @@ IB_DESIGNABLE @interface FXPageControl : UIControl | |
@property (nonatomic, assign, getter = isWrapEnabled) IBInspectable BOOL wrapEnabled; | ||
@property (nonatomic, assign, getter = isVertical) IBInspectable BOOL vertical; | ||
|
||
@property (nonatomic, strong) IBInspectable UIImage *dotImage; | ||
@property (nonatomic, assign) IBInspectable CGPathRef dotShape; | ||
@property (nonatomic, assign) IBInspectable CGFloat dotSize; | ||
@property (nonatomic, strong) IBInspectable UIColor *dotColor; | ||
@property (nonatomic, strong) IBInspectable UIColor *dotShadowColor; | ||
@property (nonatomic, assign) IBInspectable CGFloat dotShadowBlur; | ||
@property (nonatomic, assign) IBInspectable CGSize dotShadowOffset; | ||
@property (nonatomic, assign) IBInspectable CGFloat dotBorderWidth; | ||
@property (nonatomic, strong, nullable) IBInspectable UIImage *dotImage; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotColor; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotShadowColor; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotBorderColor; | ||
|
||
@property (nonatomic, strong) IBInspectable UIImage *selectedDotImage; | ||
@property (nonatomic, assign) IBInspectable CGPathRef selectedDotShape; | ||
@property (nonatomic, assign) IBInspectable CGFloat selectedDotSize; | ||
@property (nonatomic, strong) IBInspectable UIColor *selectedDotColor; | ||
@property (nonatomic, strong) IBInspectable UIColor *selectedDotShadowColor; | ||
@property (nonatomic, assign) IBInspectable CGFloat selectedDotShadowBlur; | ||
@property (nonatomic, assign) IBInspectable CGSize selectedDotShadowOffset; | ||
@property (nonatomic, assign) IBInspectable CGFloat selectedDotBorderWidth; | ||
@property (nonatomic, strong, nullable) IBInspectable UIImage *selectedDotImage; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotColor; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotShadowColor; | ||
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotBorderColor; | ||
|
||
@property (nonatomic, assign) IBInspectable CGFloat dotSpacing; | ||
|
||
|
@@ -92,15 +90,18 @@ IB_DESIGNABLE @interface FXPageControl : UIControl | |
@protocol FXPageControlDelegate <NSObject> | ||
@optional | ||
|
||
- (UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index; | ||
- (nullable UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index; | ||
- (CGPathRef)pageControl:(FXPageControl *)pageControl shapeForDotAtIndex:(NSInteger)index; | ||
- (UIColor *)pageControl:(FXPageControl *)pageControl colorForDotAtIndex:(NSInteger)index; | ||
|
||
- (UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index; | ||
- (nullable UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index; | ||
- (CGPathRef)pageControl:(FXPageControl *)pageControl selectedShapeForDotAtIndex:(NSInteger)index; | ||
- (UIColor *)pageControl:(FXPageControl *)pageControl selectedColorForDotAtIndex:(NSInteger)index; | ||
|
||
@end | ||
|
||
|
||
#pragma GCC diagnostic pop | ||
NS_ASSUME_NONNULL_END | ||
|
||
|
||
#pragma clang diagnostic pop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding making the IBOutlets strong, could you point me to documentation stating that weak is not recommended? I read the opposite in this doc.
Also connecting an Outlet from Xcode defines it as weak by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admit Apple documentation is confusing. So I remade the IBOutlets from XCode just to confirm. Also, doc specifies
The strong outlets are frequently specified by framework classes (for example, UIViewController’s view outlet, or NSWindowController’s window outlet)
, that's why I did this change. I honestly think it's more dangerous to have it as weak than strong, as I already experienced crashes related to weak outlets in production, but I can revert if you think it's better.Screen.Recording.2023-07-26.at.9.07.59.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen both happen by default. For example when you build a UIViewController and want to connect its
view
to the controller class it defaults to strong (as thatview
should be strong). But for other views which are subviews of the mainview
it will default to weak (because subviews will be strongly referenced by their parent). This means as long as a view is in the view hierarchy it should not be deallocated and you should have no issue. However if you plan to remove the view you will have to strongly reference it if you plan to continue using it afterwards.I think it is best to revert unless there are reproducible crashes which I would rather think could be linked to how the views are used. It might make sense to switch some of the outlets to strong if the use cases require it (rather than just switching everything)