Skip to content

Conversation

@ApolloZhu
Copy link

@ApolloZhu ApolloZhu commented Dec 20, 2016

Since the repo is no longer maintained, use this in your Podfile instead:

pod 'MaterialKit', :git => 'https://github.com/ApolloZhu/MaterialKit.git'

or in your Package.swift:

.package(url: "https://github.com/ApolloZhu/MaterialKit.git",
         .upToNextMinor(from: "0.6.6")),

This version is compatible, theoretically, with any version from Swift 3 to 5 (solve #63 and #72)

This implementation also removed the strong reference cycles (which are causing memory leaks).

I'm aware of this issue a long time ago, but had no idea why just declaring superLayer as weak causes unexpected crashes. Thanks to @theMeatloaf for his solutions in Swift 2, we only need to manually remove the observers by calling recycle method of MKLayer and MKRefreshControl if a class owns such properties directly. I can't figure out a way for us to automatically remove the observers, especially when the time deinit of MKLayer gets called, superLayer is already nil. Therefore, if you have a better solution, please definitely help.

And yes, in addition to MKLayer and all other classes that has a property of type MKLayer, MKRefreshControl has strong reference loop and observer not removed, and MKSwitch has a strong reference loop, too.

Finally able to solve? this: LiulietLee/Pick-Color#2
MKLayer’s superLayer observers
MKRefreshControl’s parentScrollView observers
MKSwitch’s parent MKSwitch

It’s sad that when containing MKLayer and MKRefreshControl, current
implementation requires calling `recycle` in `deinit`…
- Remove self, type delcaration, use lazy init, parameter same as
default
- Merge if-let, use optional changing for short ones, use implicit
unwrapped for guaranteed,
- Replace file private with private, provide public init for an open
class
- Update README
@ApolloZhu ApolloZhu changed the title Update to Swift 3, solve memory leaking Update to Swift 3 and 4, solve memory leaking Sep 28, 2017
@ApolloZhu ApolloZhu changed the title Update to Swift 3 and 4, solve memory leaking Update to Swift 3~4.2 (Xcode 8~10 beta 4) + Solve memory leaking Jul 25, 2018
@ApolloZhu ApolloZhu changed the title Update to Swift 3~4.2 (Xcode 8~10 beta 4) + Solve memory leaking Update to Swift 3~4.2 (Xcode 8~10.1) + Solve memory leaking Mar 13, 2019
as in Xcode 10.2 beta 4 (10P107d)
Why is NS_EXTENSION_UNAVAILABLE or APPLICATION_EXTENSION_API_ONLY not a thing in Swift?
@ApolloZhu ApolloZhu changed the title Update to Swift 3~4.2 (Xcode 8~10.1) + Solve memory leaking Update to Swift 3~5 (Xcode 8~10.2) + Solve memory leaking Apr 5, 2019
@ApolloZhu ApolloZhu changed the title Update to Swift 3~5 (Xcode 8~10.2) + Solve memory leaking Update to Swift 3~5 (Xcode 8~11.2.1) + Solve memory leaking + SPM Nov 6, 2019
@ApolloZhu ApolloZhu changed the title Update to Swift 3~5 (Xcode 8~11.2.1) + Solve memory leaking + SPM Update to Swift 3~5 (Xcode 8~11.2.1) + Resolve memory leaks + SPM support Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant