当前位置: 动力学知识库 > 问答 > 编程问答 >

swift - Why Do iOS 9 Methods Still Work on iOS 8.4?

问题描述:

I wanted to use the @warn_unused_result @rethrows func filter(@noescape includeElement: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element] method in one of my projects. The App should run on iOS 8 and later. If I look the method up in the documentation it says "Availability: iOS (9.2 and later)"

However, if I call the method on iOS 8.4 it works w/o any issues.

Any ideas why the documentation says iOS 9.2 but it still works on iOS 8.4? So can I call it w/o any availability check and be sure it won't crash in the future?

Thanks in advance!

网友答案:

This is the part of Swift standard library, it doesn't depend on iOS SDK at all. Swift runtime is bundled with application, so for the system it doesn't matter which version of Swift application was written in. I assume that this availibility mark might have something in common with the change which was made to filter function in Swift 2. Look at those two docs: Swift 2.1 Swift 1.2

As you can see, declarations of those two methods are different.

分享给朋友:
您可能感兴趣的文章:
随机阅读: