TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

8 Surprises I learnt about Swift

2 点作者 ahigherugliness超过 9 年前

1 comment

coldtea超过 9 年前
&gt;<i>I was surprised to find out that tuples are not AnyObjects. The reason is that AnyObject corresponds to an Objective-C object, an object that can exist in the Cocoa world. We still write apps in the Cocoa framework so mostly we deal with AnyObjects. And often times (in the case of strings for instance) there is implicit bridging between the two sorts of objects. Then there is also an Any object, which is not (necessarily) an AnyObject, but is the Swift equivalent of the Objective-C general object (represented in Swift by AnyObject). All very confusing, and inexplicably confusing if you consider that Swift had a chance to start with a clean slate.</i><p>How is that confusing, and much more &quot;inexplicably&quot; so?<p>It&#x27;s clearly because Swift wanted to take advantage of its clean slate that this is the case. So you have AnyObject for items that need the legacy Objective-C object tree support, and Any for the Swift native equivalent.<p>Eventually this allows them to drop AnyObject, and keep Any when they&#x27;re finally able to go all-Swift.