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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintain arranged subviews array #56
Conversation
@@ -84,7 +84,7 @@ typedef NS_ENUM(NSInteger, OAStackViewAlignment) { | |||
NS_ASSUME_NONNULL_BEGIN | |||
@interface OAStackView : UIView | |||
|
|||
@property(nonatomic,readonly,copy) NSArray *arrangedSubviews; | |||
@property(nonatomic,readonly,copy) NSMutableArray *arrangedSubviews; |
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 think the idea was to replicate UIStackView API, and in Apple docs arrangedSubviews
is NSArray
.
You could keep public array as immutable, and provide private mutable array, of which immutable copy could be returned getter of arrangedSubviews
.
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.
Looks good except the different API. As Grubas7 said I'd keep a mutable version internally (with a different property name) and override the arrangedSubviews getter to return a (non mutable) copy of the mutable array. This will allow you to keep the arrangedSubviews property in the header as an NSArray
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.
Will do
@bencallis Done! |
+1 would love to see this merged. |
This looks fantastic, sorry for the late action, I will be merging it this weekend, thanks for the addition :) |
Awesome, thanks! 馃嵏 |
@@ -16,6 +16,7 @@ | |||
|
|||
@interface OAStackView () | |||
@property(nonatomic, copy) NSArray *arrangedSubviews; |
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.
Since this property is not used anymore I have removed it after rebasing.
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.
No, this property is used in line 76. It's provided to be consist with iOS9 API.
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.
yes its used in line 76 but the backing property and its Ivar are not needed. I only removed the property from the .m file, the .h file still has the readonly one.
@agelber Great addition! I have rebased it and will merge it in a moment. Thanks for this PR! |
Cheers! |
Hi guys. Thanks for fixing the problem with the |
Hi!
Firstly, thanks for working on this, I just started using and it made my life a lot simpler! 馃樅
I was missing the
arrangedSubview
functionality, as also mentioned in #43, so tried to add it, including accompanying specs.The solution is just for
arrangedSubviews
to be mutable, initialized as either empty or with the passed in initial views and update it accordingly when inserting or removing subviews.There is another possible enhancement, so that every place where now
self.subviews
is used, to useself.arrangedSubviews
and completely ignore any subviews which aren't array, but I'm not sure if that's a valid option in your opinions, so I haven't implemented that here yet.Would love to hear feedback!
Cheers! 馃嵒