Have you ever wondered how Alamofire extends native elements by attaching a domain-like suffix
.af to Foundation objects (e.g.
URLSessionConfiguration) instead of adding the desired functionality directly? Or why RxSwift (shout-out to Shai Mishali 👋) extends every component of UIKit by adding an
.rx extension? In this article, I’m excited to share the answers to these questions with you.
There’s no better way to explain things than by showing an example. So, let’s build a framework suffix extension of our own!
We’ll start by creating a wrapper that is expected to hold extended types:
Writing tests has always been a nontrivial task, especially if the code you are testing is mainly asynchronous (i.e., a tested method receives callback as one of its parameters). Although a callback-style function invocation is entirely appropriate within a program, this style doesn’t fit so well into a unit test environment.
I strongly believe in the rule of thumb that a unit test should be as simple as possible. It has the word “unit” in the definition for a reason: to emphasize that it shouldn’t be complicated. Based on my experience, a well-written unit test is:
The Factory Method has been a well-known and broadly used pattern amongst developers for quite some time. If you’re completely unfamiliar with the pattern, I recommend first read this explanation, maybe look at its implementation in Swift, and then return to this article, in which I’ll show this pattern in a slightly different light.
The first association which comes to mind when you hear the word “Generics” is “strongly typed”. Therefore, you would probably ask: “What does Factory have to do with Generics? Isn’t the pattern, in all its variations, implemented using pure abstractions?” And you would be right, my…
I am going to introduce you to my short scripts, written on bash, for creating fat frameworks, libraries and xcframeworks. Those of you who have encountered with 3rd party code distribution on iOS must have heard those terms and must know that this topic is nebulous and ill-defined. Apple also doesn’t provide clear documentation on how to create these frameworks as they do for other subjects (at least I haven’t found any). However, even if you haven’t been exposed to these terms before, I hope you will still find this article relevant and it will serve as a useful reference.
Hi there! How many times you’ve asked yourself if there’s any b̵e̵t̵t̵e̵r cleaner way to write your application logic not only using if-else statements? Good news, in Swift, there is one indeed! And that’s using swift protocols extension power combined with generics. Let’s look at the example.
Before we start, a little preamble. Not a long time ago, my fiance left for a couple of days to visit her family abroad. While missing her a lot, I created this little Playground:
As you can see, it’s pretty straight forward. I use a swift protocol extension feature to create some…
Hi, guys! I’d like to share with you a little shell script I prepared. It’s short and simple, but like any useful script, it can save you time by doing a daily routine for you. I’m talking about opening Pull Requests, or to be more exact git commands probably anyone will run before opening PR.
As you can see, I left the last step empty, as it may change depending on what you decide on doing next in each of your repositories after you’ve got your branch prepared for PR to be opened. …