fix Any? cast to protocol always nil in ios 13 #2182
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is a swift bug, In iOS 13 or earlier versions.
cast an Any? to protocol will always get nil
https://stackoverflow.com/questions/42033735/failing-cast-in-swift-from-any-to-protocol
In my case i use backgroundDecode option when download image, and if the image is a GIF the animate will lost, because the
decode
func not return itselfThe
frameSource
always get nil, because theT
ingetAssociatedObject
func isImageFrameSource
it is a protocol, so always return nilThe fix is first casting to AnyObject and then casting to the protocol
This swift bug was fixed in ios14 and macos 11 runtime