A compendium of shapes using paths

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

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…


Use the power of Combine and SwiftUI grids to create a maze in your SwiftUI app

Maze
Maze
Photo by Tobias Rademacher on Unsplash.

I was looking through The Pragmatic Programmers’ bookshelf for weekend reading and stumbled across Mazes for Programmers by Jamis Buck. As I read the description (“Remember when programming used to fun?”), something clicked inside me. Yes, I recalled it is fun, but then I realised the code illustrating the algorithms was using Ruby, a Python-like language I don’t know very well.

As I looked through the book, all the algorithms are described as well illustrated in code. I decided to try to rewrite them in Swift.

Just before I jumped in with both feet, I made a backup plan and…


— The road to follow —

Photo by Joe Calata on Unsplash

Why should you learn to code? Because it is skill that only 18.5 million individuals have in a world of 4 billion — and well when you think about the internet of things [iOT] really starting to take off, almost everything you buy will need programming. Code that 0.25% of the global population will be writing and you’re be using.

Indeed if you need more convincing watch the netflix series called “explained” on the subject, focus on the episode entitled “coding”. …


The Trial

I am reading the news on the net about the Apple trial, you know the one between Epic Games and Apple.

Epic Games want a bigger slice of the pie and Apple want to keep the status quo. There are two issues at its heart it seems. The first is that Apple charge a whopping thirty percent commission on all in in-app purchases sales. I say whopping, because let’s be honest Apple it is rather a lot.

Sales tax, which in effect what we’re talking about here is charged by governments all over the world. In the UK…


Bonjour over a network framework in iOS

Storefront that reads “Bonjour.”
Storefront that reads “Bonjour.”
Photo by Faisal Waheed on Unsplash.

I’m sure you’ve heard the saying “The secret to success is networking.” I suspect it’s also the secret to building killer apps. Let’s take a journey through the tech you can use to connect your apps (aka sockets).

OK, there are two flavours: TCP and UDP. In short, TCP sockets guarantee delivery, whereas UDP sockets do not. TCP sockets are useful when you need to be sure the message you sent arrived. UDP sockets are useful when you’re more concerned with speed.

On to the code then. Now, as with all conversations, we have somebody talking and somebody listening. This…


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…

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