Archive for January 6, 2017

Friday, January 6, 2017

Unsafe Swift: Using Pointers and Interacting With C

Ray Fix (via Greg Heo):

MemoryLayout<Type> is a generic type evaluated at compile time that determines the size, alignment and stride of each specified Type.

[…]

Unsafe Swift pointers use a very predictable naming scheme so that you know what the traits of the pointer are. Mutable or immutable, raw or typed, buffer style or not. In total there is a combination of eight of these.

[…]

This example is similar to the previous one, except that it first creates a raw pointer. The typed pointer is created by binding the memory to the required type Int. By binding memory, it can be accessed in a type-safe way. Memory binding is done behind the scenes when you create a typed pointer.

[…]

Never bind memory to two unrelated types at once. This is called Type Punning and Swift does not like puns. Instead, you can temporarily rebind memory with a method like withMemoryRebound(to:capacity:). Also, the rules say it is illegal to rebind from a trivial type (such as an Int) to a non-trivial type (such as a class). Don’t do it.

Previously: Passing an Array of Strings From Swift to C, Swift 3.0 Unsafe World, Swift and C Libraries.

Bitter iCloud Truth

Daniel Jalkut:

The first thing to do was obviously to take care of those duplicates. Contacts on the Mac features a couple seemingly handy menu items for dealing with this problem: “Look for Duplicates” and “Merge Selected Cards.” I cannot recommend using either of these features.

[…]

After painstakingly merging cards in this manner for an hour or so (!), I had stopped paying close attention to whether conflicting data was being persisted well or not. At one point I stumbled upon the realization that I lacked the phone number for a contact whom I had sent an SMS message just within the past week. Other contacts were missing key data, too. An outdated email address here, a missing mailing address there. Whoops! Abort mission! Time to recover from that backup file.

[…]

I began to panic. Had I actually lost all of my Contacts data? In spite of dutifully backing up my local data and making a proactive archive from Contacts, the app had a very different idea of what my Contacts “truth” was.

On my Mac, the archive does seem to contain the data from iCloud, but I don’t dare to try restoring from it. It’s not clear to me what I would lose by creating a local vCard export instead of a Contacts Archive.

Chuq’s Advice for Apple

Chuq Von Rospach:

If I could only offer one thing to Apple, it’s this: “it’s okay to slow down — a little”. The iPhone has to ship a new version ever year, and you can’t take your eye off that for a minute, but other parts of the product line don’t need that kind of continuous update. MacOS would be okay with a new release every 18 months or two years, or a feature release as a tick and a performance release as a tock in a two year cycle.

[…]

When people are nervous, when they don’t know what might happen to the things they depend on in their life and work, they start speculating. And when there’s nothing to fill the space in the social media and online conversation space, that speculation ends up taking on a life of its own, especially the speculations of the better known, louder enthusiasts and influencers. The best antidote for that is to get in front of it with enough information to prefer the speculations from catching everyone’s attention in the first place.

[…]

I find it interesting that Apple seems to have chosen the “Tim writes an internal email that he likely knows will get leaked” as a tactic here, because I’m guessing it being a leak prevents it from being liable to the same kind of SEC “forward thinking” rules and regulations that his more formal communications might be held to. Nice hack.

Previously: Apple’s 2016 in Review.

The State of Safari Extensions

honestbleeps (via Peter Steinberger, Hacker News):

A little over a year ago, Apple announced that Safari extension developers would no longer be able to develop extensions for free. Instead, they had to pay the same $100 per year that iOS and MacOS developers do. The benefit, they alleged, is that you’d get the tools and support to develop iOS and MacOS apps in addition to Safari Extension development. According to them, this “simplified” their program.

[…]

All of the browsers’ extension galleries require that you submit your extension for review. Each of them, except Safari, has some automated processes to ensure you’ve checked all the right boxes and included all the right files and data. The fact that we waited two weeks to be notified of such a simple omission, and one that wasn’t noted in the first rejection, is pretty awful.

So, we submitted yet again, once again providing documentation of our license to use the term “reddit” in the name, just in case. What happens? We wait a few weeks and are once again rejected for using the term “reddit” in the name of our extension!

[…]

All four of the other browsers use effectively the same APIs — Safari is potentially going to change that in some ugly ways.

To develop a Safari extension may eventually require Xcode, rather than whatever editor a developer prefers to use.

honestbleeps:

The difference with Edge vs Safari is that Edge spent time getting extensions right. They worked directly with extension developers (including me!) to ensure that Edge supported as much of what RES needed as possible. I was even flown out to Microsoft to work with their developers for a day and help them get RES running.

Microsoft showed us a great deal of kindness and respect. Apple has essentially given us the middle finger.

OmniFocus 2.8 for Mac

The Omni Group:

In OmniFocus 2.8, basic search works the same way it has since 2014: Click into the Toolbar Search field or hit ⌥⌘F and type the string you’re looking for. The outline and sidebar are filtered to show just items in your current view that contain that string (if there are any). The part that’s new in 2.8 is that instead of being limited to just searching the current view, you can click the magnifying glass icon in the search field and expand the scope! The three search scope options (Here, Remaining, and Everything) mirror the search options available in OmniFocus on iOS.

Previously, I would have to create a new window that showed everything—I have a perspective for that—in order to do a global search. It turns out that I still prefer the perspective way because I can drive it from the keyboard. I can have a keyboard shortcut to open the perspective and then just close the window when I’m done. With the new global search, I have to use the mouse to change the search scope to global before the search and also to change it back afterwards.

See also: the full change list.

Stringify Automation Service

Jeff Porten:

Stringify sounds to me like the Internet automation service IFTTT on steroids (and if you’re not sure what IFTTT does, see “IFTTT Automates the Internet Now, but What Comes Next?,” 20 December 2013). IFTTT allows for one condition and one event; Stringify has multiple conditions and creates “macros” for the real world, like “if it’s after 7 PM, my motion sensor outside is tripped, and I’m not home, turn on my lights and send me a text.” Better yet, Stringify integrates with IFTTT so one can trigger the other and vice versa. Just as with IFTTT, I’m unclear on how Stringify plans to make money.

Previously: IFTTT Drops Pinboard and App.net, Blames Them.