A compendium of shapes using paths

Image for post
Image for post

In part 1 and 2 of this series I covered isosceles polygons, equilateral triangles, right + left angles triangles, parallelograms and trapezoids; putting together routines to build them using methods based on circles. You can find the stories here. Shapes that you can mutate and animate to your hearts content in code.

At the end of part 1 I mentioned that we would return to the triangles and indeed in part 2 developed a routine that I want to take further in this article. Further to try and do some more triangles. The plan to do the sort I missed…


A compendium of shapes using paths

Image for post
Image for post

In part 1 of this series I covered polygons principally, putting together routines to build them using paths a couple of methods based on circles. You can find the story here. Shapes that you can mutate and animate to your hearts content in code.

We covered a lot shapes in fact in part one, but well we still got a few to think about. What’s missing. We don’t have a parallelogram or a trapezoid. Two shapes that are vary similar.

Here is an Apple text book answer for a parallelogram.

struct Parallelogram: Shape { @State var percent: Double func path(in…


Let’s solve real-world problems with the declarative framework

Substances blending into each other
Substances blending into each other
Photo by Bailey Heedick on Unsplash.

During the WWDC talk on the new Combine framework, the presenter told the audience that it was very much a mix-and-match solution, with Swift supporting declarative and imperative coding alongside each other.

With that thought in mind, I decided to look at converting some code from one to the other using a problem grounded in reality. This challenge is more relevant today than it has ever been considering the current need to unsort or randomise a set of patients’ records for a drug trial. …


Customising the humble iOS switch in your SwiftUI apps

Pink tablet
Pink tablet
Photo by Hillary Black on Unsplash.

The style keyword appears in a number of constructs in Swift. I think it is a tool few of us really use, which is a lost opportunity in the case of SwiftUI since you can do some interesting things with “standard” components if you start working with it.

In this article, we will explore how you can use the style options on a component to make your interface stand out from the crowd.

I want to focus on Toggle here, although the same principles can be applied to Button. Before I jump in, two brief warnings:

  • Make sure you take…


Using Just, Sequence, Record, and Future within SwiftUI

Combine publishers in action
Combine publishers in action
GIF by the author.

Publishers are the lifeblood of the Combine framework, and there are a dozen or more of them. In this article, I want to try to change the background color of a “Hello World” greeting by using some of the main publishers available.

I don’t claim this is the right or best way to do the task. This is more of an exercise to understand how these publishers work and how you can make them work for you.

Preamble

One of the most difficult aspects of using publishers is the fact that you can terminate the stream if you’re not careful —…


A look at how to use subscriptions in Combine work

Subscribers are the lifeblood of business models around the world, indeed they are the way things seem to be going when it comes to buying software these days. And we already have them in Swift with in-app purchases a subject I wrote about in this paper.

So, it seems fitting that they're moving into mainstream software engineering within it too. Subscriptions a major component of the new Combine Framework. Join me on an exploration of how a major component/aspect of them works. Cancellation.

Now the Combine framework has three principal players — The Publishers, the Subscribers, and the Operators. The…


Demystify this tricky operator to build reactive iOS apps

Terms arranged in a number of different ways
Terms arranged in a number of different ways
Photo by the author.

If you watched the Introducing Combine WWDC 2019 talk by Tony Parker, you could be forgiven for thinking that using Combine is a walk in the park. He defined the new Combine framework as a unified, declarative API for processing values over time. The framework has just three major components: publishers, subscribers, and operators. Listening to Tony, it all sounded very straightforward. And to be fair to Apple, most of it is.

But there is one operator that isn’t that easy to get your head around: the flatMap operator.

It is different from the others in that most — if…


The good, the bad and the ugly

Image for post
Image for post
Photo by Sigmund on Unsplash

I have spend the last three months on courses using Zoom, and I have not finished yet — but after Friday’s session I thought I put to pen to paper to write down some advice for Zoomers around the world. Using it well, using it poorly, shouldn’t have bother use it at all.

  • Devices. — maybe you don’t have much choice when it comes to devices; but clearly some are better than others. If your gamer or a YouTuber, maybe you have a desktop with a separate camera and microphone— the gold standard — although I say it with a…

A journey to look at how I can swap one for the other

Image for post
Image for post
Photo by Antoine Dautry on Unsplash

In 2019 Apple published two declarative frameworks, SwiftUI and Combine. Which has had me thinking this month and indeed published a couple of articles on the subject, ones like this. Getting Combine to work is fun, really. Maybe not quite as exciting as SwiftUI, but it is interesting and rewarding I promise.

On a related but different note— I am sure you know what I am talking about if you find articles somewhat academic at times— full of examples that you cannot seem to fit into the real world. Let’s kill two birds with one stone.

So with that thought…


A look at getting the true time and date.

Time is unique in the modern world because it is one of the very few things we all agree on. Yes, it’s true the Americans, the Russians, the Chinese, absolutely everyone on the planet agree about this one thing — time. Of course it hasn’t always been that way, in fact it wasn’t until 1884 that the world agreed to agree what the time is. Implicit within that agreement we have this concept of hours, minutes and seconds too, units we also thankfully agree on.

What’s really useful from a coding point of view about this agreement and its units…

Mark Lucking

Coding for 35+ years, enjoying using and learning Swift/iOS development. Writer @ Better Programming, @The StartUp, @Mac O’Clock, Level Up Coding & More

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store