Archive for November 2, 2018

Friday, November 2, 2018

The Power of Key Paths in Swift

John Sundell:

Let’s see if key paths again can help us make the above syntax a bit simpler, and if we also can get rid of that weak self dance we so often have to do (and with it - the risk of accidentally introducing retain cycles if we forget to capture a weak reference to self).

Since all we’re really doing above is to take the value that was passed to our closure and assign it to a property on our view controller - wouldn’t it be cool if we were actually able to pass the setter for that property as a function? That way we could pass that function directly as the completion handler to our load method and everything would just work.

To make that happen, first let’s define a function that lets us convert any writable key path into a closure that sets the property for that key path. For this, we’ll use the ReferenceWritableKeyPath type, since we want to restrict this to reference types only (otherwise we’d only make changes to a local copy of a value). Given an object and a key path for that object, we’ll automatically capture the object as a weak reference and assign the property matching the key path once our function gets called - like this[…]

Depth Capture With the iPhone XR

Ben Sandofsky:

The iPhone 7 Plus introduced a dual-camera system, which enables a similar way to construct depth. By taking two photos at the same time, each from a slightly different position, we can construct a disparity map.


With the iPhone X, Apple introduced the TrueDepth camera. Instead of measuring disparity, it uses an infrared light to project over 30,000 dots. […] However, depth data isn’t entirely based off the IR dots.


In a DPAF [Dual Pixel Auto Focus] system, each pixel on the sensor is made up of two sub-pixels, each with their own tiny lens. The hardware finds focus similar to a rangefinder camera; when the two sub-pixels are identical, it knows that pixel is in focus.


If you captured two separate images, one for each set of sub-pixels, you’d get two images about one millimeter apart. It turns out this is just enough disparity to get very rough depth information.

The iPhone XR combines this with machine learning to capture depth for Portrait mode.

John Gruber:

I’m so glad Halide offers this, but I can see why Apple hasn’t enabled it for non-human subjects in the built-in Camera app. It’s hit or miss.

Previously: iPhone XR Reviews.

Developing an iOS App in 2018

Renaud Lienhart:

Disregarding the limited utility of the app for most of you, I’d just like to quickly talk about how developing an iOS app from scratch in 2018 feels like.

First of all, the basic architecture of the app: we use MVVM-Rx layered in modules, and the only couple “real” dependencies we have is RxSwift and RxDataSources.

The vast majority of the code is purely functional and reactive. It is a pleasure to read as well as to write.

Secondly, Swift.

From Value Types to CaseIterable, passing by Decodable, Generics, Auto-Synthesised E&H conformances, Keypaths and the power of its Enums, Swift has become an essential pillar of the code we write.

I love Objective-C, but I would never want to go back.

Apollo Pulled From the App Store for Charging for Push Notifications

Chance Miller (MacRumors):

After a feature-rich update over the weekend, Apollo for Reddit has today been removed from the App Store. Developer Christian Selig took to Reddit to explain that he received an email from the App Store Review team explaining that his app violates App Store Guidelines by offering push notifications as an in-app subscription upgrade.


What makes Apple’s approval and subsequent rejection puzzling, however, is that Selig worked directly with Apple to ensure the update did not violate the App Store Guidelines. He was originally told by Apple that so long as he bundled realtime push notification support with other features, such as theming and custom app icons, the update would be approved and not in violation of the guidelines.

Even assuming Apple’s decision had been correct, it’s rude to just remove the app from sale before even talking with the developer. It’s not as if the app was hurting anyone.

Ryan Jones:

This is f’ing bullshit trash. The IAP is for server-side push, but even if it wasn’t this is trash.

Apple is policing guys like us for this ticky tap crap when everyone making sustainable money is using scam IAP’s.

You’re allowed to scam people out of $150 with $3/week trick IAP screens that’s only option are “Continue” or “Subscribe” with a tiny X for close in the corner.

But you can’t charge for server-side push. NO!

Friggin YouTube’s premium subscription at $15/week is for BACKGROUND AUDIO. But nooo, that’s not breaking the rules because they are a big company.

If you are a scam app or a big ass company you can break all the rules. This is the ENTIRE POINT of a walled garden.

You have to protect users from the asshats that show up anywhere there is money from scamming people. Nope, not gonna do that, $150/year for weather is FINE. $8/week for live wallpapers is FINE.

We’re too busy over here policing Indie apps.


Also true #1, if Apollo didn’t have a following - he’d be super screwed. I’ve personally spent MONTHS convincing app review of trivial bullshit.

Also true #2, users are already hesitant to pay for ANYTHING because of sub scams.

Christian Selig:

Update: got off the phone with the same incredibly nice person who called a few weeks back, and the removal was a mistake that they just corrected. A+ turn around time, and mistakes happen.

Collin Allen:

This whole thread. It’s frustrating that legitimate apps still run into App Store red tape, yet the obviously scammy apps seem to sail right through. The whole point of having the iOS walled garden is to keep out garbage, yet any given App Store search is filled with it.

Previously: Apple Pulling High-Grossing Scammy Subscription Apps Off the App Store, Rejected From the App Store for Emoji in Screenshot, Out of Touch.