Archive for December 20, 2023

Wednesday, December 20, 2023

Triggering Swift Property Observers From Initializers

Natalia Panferova:

In Swift, property observers such as willSet and didSet are not called when a property is set in an initializer. This is by design, as the initializer's purpose is to set up the initial state of an object, and during this phase, the object is not yet fully initialized. However, if we need to perform some actions similar to what we'd do in property observers during initialization, there are some workarounds.

Ole Begemann:

When a Swift property has a willSet clause, any mutation of that property will be made on a temporary copy.

⇒ At least two copies exist during the mutation.

⇒ This defeats the copy-on-write optimization for Array, String, etc. (which relies on uniquely referenced buffers).

⇒ A property of a COW type with a willSet will copy its contents on every mutation.

Relevant for SwiftUI code because @Published uses willSet: every mutation of a @Published var array: [T] will copy the array contents.

This happens even if the willSet doesn’t actually use the new value, e.g. if it was just being used to trigger a notification.

Previously:

Dictation and Predictive Text in macOS Sonoma and iOS 17

Kirk McElhearn:

It may seem counterintuitive to dictate and type at the same time, but there is a reason for this. As you dictate, you will find that the accuracy of the transcription is far from 100%. Previously, when you spotted mistakes to correct while dictating, you would have to stop dictating, correct the mistakes, and then pick up again. Now, you can keep the dictation active while you are correcting misunderstood words. If you dictate a lot, this can save you a lot of time. I find that it’s much easier to correct as I go along, rather than waiting until I get to the end of a long paragraph and going back to fix errors.

Another reason is that there are symbols and special characters that are not very easy to dictate. Apple has a support document explaining how to dictate many of these characters, but I find that they don’t always work. And you may need other special characters that you can’t dictate.

When dictating in this mode, you’ll see the blue cursor visible at the end of your dictation, waiting for you to continue. Previously, after you stopped talking for a few seconds, your device would stop listening. At this point, you can type, and when you start dictating again, your Mac picks up its transcription where your cursor is located.

[…]

To enable predictive text on the Mac, go to System Settings > Keyboard > Text Input.

Previously:

Google Groups Ending Support for Usenet

Google (via Hacker News):

Starting on February 22, 2024, you can no longer use Google Groups (at groups.google.com) to post content to Usenet groups, subscribe to Usenet groups, or view new Usenet content. You can continue to view and search for historical Usenet content posted before February 22, 2024 on Google Groups.

In addition, Google’s Network News Transfer Protocol (NNTP) server and associated peering will no longer be available, meaning Google will not support serving new Usenet content or exchanging content with other NNTP servers.

The Original iPhone Demo

Fred Vogelstein (2013, via Hacker News):

The software in the iPhone’s Wi-Fi radio was so unstable that Grignon and his team had to extend the phones’ antennas by connecting them to wires running offstage so the wireless signal wouldn’t have to travel as far. And audience members had to be prevented from getting on the frequency being used. “Even if the base station’s ID was hidden” — that is, not showing up when laptops scanned for Wi-Fi signals — “you had 5,000 nerds in the audience,” Grignon says. “They would have figured out how to hack into the signal.” The solution, he says, was to tweak the AirPort software so that it seemed to be operating in Japan instead of the United States. Japanese Wi-Fi uses some frequencies that are not permitted in the U.S.

[…]

Then, with Jobs’s approval, they preprogrammed the phone’s display to always show five bars of signal strength regardless of its true strength. The chances of the radio’s crashing during the few minutes that Jobs would use it to make a call were small, but the chances of its crashing at some point during the 90-minute presentation were high. “If the radio crashed and restarted, as we suspected it might, we didn’t want people in the audience to see that,” Grignon says. “So we just hard-coded it to always show five bars.”

None of these kludges fixed the iPhone’s biggest problem: it often ran out of memory and had to be restarted if made to do more than a handful of tasks at a time. Jobs had a number of demo units onstage with him to manage this problem. If memory ran low on one, he would switch to another while the first was restarted.

Ben Thompson:

The part of the Gemini announcement that drew the most attention did not have anything to do with infrastructure or data: what everyone ended up talking about was the company’s Gemini demo, and the fact it wasn’t representative of Gemini’s actual capabilities.

[…]

Google, given its long-term advantages in this space, would have been much better served in being transparent, particularly since it suddenly finds itself with a trustworthiness advantage relative to Microsoft and OpenAI. The goal for the company should be demonstrating competitiveness and competence; a fake demo did the opposite.

Previously:

Measuring the Data iOS and Android Send to Apple and Google

Douglas J. Leith (2021 PDF, via John Opdenakker, ArsTechnica)

We investigate what data iOS on an iPhone shares with Apple and what data Google Android on a Pixel phone shares with Google. We find that even when minimally configured and the handset is idle both iOS and Google Android share data with Apple/Google on average every 4.5 mins. The phone IMEI, hardware serial number, SIM serial number and IMSI, handset phone number etc are shared with Apple and Google. Both iOS and Google Android transmit telemetry, despite the user explicitly opting out of this. When a SIM is inserted both iOS and Google Android send details to Apple/Google. iOS sends the MAC addresses of nearby devices, e.g. other handsets and the home gateway, to Apple together with their GPS location. Users have no opt out from this and currently there are few, if any, realistic options for preventing this data sharing.

[…]

During the first 10 minutes of startup the Pixel handset sends around 1MB of data is sent to Google compared with the iPhone sending around 42KB of data to Apple.

[…]

The high frequency of network connections made by both iOS and Google Android (on average every 4.5 minutes) therefore potentially allow tracking by Apple and Google of device location over time.

Hopefully they aren’t logging.

Thomas Germain (January 2023, via Hacker News):

France’s data protection authority, CNIL, fined Apple €8 million (about $8.5 million) Wednesday for illegally harvesting iPhone owners’ data for targeted ads without proper consent.

[…]

Apple failed to “obtain the consent of French iPhone users (iOS 14.6 version) before depositing and/or writing identifiers used for advertising purposes on their terminals,” the CNIL said in a statement. The CNIL’s fine calls out the search ads in Apple’s App Store, specifically.

[…]

With iPhones running iOS 14.6 and below, Apple’s Personalized Advertising privacy setting was turned on by default, leaving users to seek out the control on their own if they wanted to protect their information. That violates EU privacy law, according to the CNIL. It doesn’t cross the Europe’s GDPR, though; the violation falls under the more obscure ePrivacy Directive of 2002.

Previously: