Closed ZevEisenberg closed 8 years ago
See here: https://github.com/oarrabi/OAStackView/blob/3569aad354210064de99a2f401ad9167fd358eba/Pod/Classes/OAStackView.m#L18
@property(nonatomic, copy) NSMutableArray *mutableArrangedSubviews;
In the code, this is only ever assigned via _mutableArrangedSubviews, so it doesn't cause problems. But if it is ever assigned via dot syntax, it will be assigned via a synthesized setter that looks something like this:
_mutableArrangedSubviews
- (void)setMutableArrangedSubviews:(NSMutableArray *)mutableArrangedSubviews { _mutableArrangedSubviews = [mutableArrangedSubviews copy]; }
_mutableArrangedSubviews is now of type NSArray, not NSMutableArray, and this code will crash if something tries to mutate it.
NSArray
NSMutableArray
The fix:
@property(nonatomic, strong) NSMutableArray *mutableArrangedSubviews;
I agree with your fix, can you please submit a PR with this fix?
Sorry I didn't see the PR, I am viewing it now.
See here: https://github.com/oarrabi/OAStackView/blob/3569aad354210064de99a2f401ad9167fd358eba/Pod/Classes/OAStackView.m#L18
In the code, this is only ever assigned via
_mutableArrangedSubviews
, so it doesn't cause problems. But if it is ever assigned via dot syntax, it will be assigned via a synthesized setter that looks something like this:_mutableArrangedSubviews
is now of typeNSArray
, notNSMutableArray
, and this code will crash if something tries to mutate it.The fix: