Archive for March 2, 2021

Tuesday, March 2, 2021

Be Careful With Obj-C Bridging in Swift

Bruno Rocha:

While visually the same, this case is completely different from the view controllers one! String does not inherit or uses NSString in any way -- they are different objects with different implementations. The way this works is that as in this case is a syntax sugar for the following[…]

[…]

Cases like this can be extremely confusing if your Swift method cannot predict where its arguments are coming from, because as we can see above, the very same object can completely change the result of an operation depending on if it was bridged or not. If it wasn’t enough, things get even worse when you deal with the fact that the very same method can have different implementations across languages[…]

[…]

I personally think that using as as a syntax sugar for bridging was not the best idea.

What it does is fine, but perhaps it should have been spelled differently.

Previously:

Update (2021-03-22): SE-0083 (deferred):

Dynamic casts using as?, as!, and is are currently able to dynamically perform Cocoa bridging conversions, such as from String to NSString or from an ErrorProtocol-conforming type to NSError. This functionality should be removed to make dynamic cast behavior simpler, more efficient, and easier to understand. To replace this functionality, initializers should be added to bridged types, providing an interface for these conversions that’s more consistent with the conventions of the standard library.

Apple TV 3 Losing More Content

Joe Rossignol:

Last week, the MLB app was removed from the third-generation Apple TV[…] A few other popular apps are being removed from the third-generation Apple TV as of this month, including YouTube and CBS All Access, the latter of which is being rebranded as Paramount+.

Zac Hall:

Developers just can’t justify putting resources behind a discontinued product that’s no longer being sold or maintained by Apple. Based on the state of streaming media affairs, we will only continue to see the third-gen Apple TV lose access to apps with no direct replacement product from Apple on the market.

I see why this is happening, but it’s frustrating because the newer Apple TVs don’t offer anything new that I want, and a 1080p box remains fine for my 1080p TV.

Previously:

Origin of macOS Poof Animation

Chris Hynes:

It used to be that when you dragged an item off the Dock and dropped it, the icon would disappear in a puff of smoke and make a satisfying noise. The animation was strangely primitive against the backdrop of the slick user interface of what used to called Mac OS X.

[…]

The intention of the designer was that these drawings would stoke further discussion. That it would get cleaned up and refined later.

Apple Developer Forums Can Now Monitor Threads

Apple (also: MacRumors):

And now, it’s easier to find and keep track of content you’re interested in. Take advantage of enhanced search and a new feature that monitors threads for you and sends you an email each time there’s a reply.

The new forums remain pretty useless, except that they are the sole source of some incredibly valuable defacto documentation written by DTS engineer Quinn.

Previously:

Update (2021-03-14): See also: The Wisdom of Quinn.

Adam Maxwell:

Quinn’s posts remind me of mmalc’s Cocoa Bindings sample code on his personal page, and his writeups on cocoa-dev. Super helpful, but sure would be nice to have IN THE FORMAL DOCUMENTATION.

Aaron Tuller:

Yes yes. I still have this in my favorites bar in Safari, can’t imagine relying solely on the reference pages.

Update (2021-05-06): Craig Hockenberry:

WTH? You can’t post an image on Apple Developer Forums?

Apple is intentionally making it hard to communicate visually. And with external links being banned, there’s no workaround.