Whenever I start a new iOS Swift project, the first thing I do is import my Utilities and Extension files. They help me make my programming more efficient. Let’s have a look at my six favorite and most essential extensions.
When implementing modern designs, dropping a shadow under a UIView
is often required. Instead of having to write multiple lines of code for each view, I use an extension:
Of course, every project might require some minor changes to the shadow style, but that can be changed in a central place.
Adding animations to your app can be a difference between appearing basic or professional. For this example, we will be using the following ready-made Design Block.
But you can create a new ViewController from scratch; learn how-to here:
The first step is to open the ViewController. The XIB we will be using in this example is called RateMeViewController
and to open it, we run:
let vc = RateMeViewController(nibName: "RateMeViewController", bundle: nil)//
// Make changes to vc (for example to modalPresentationStyle)
//self.present(vc, animated: true)
This would open the ViewController without any fancy animations, but we want moooore. So, to…
When projects grow, it becomes handy to modularize not only your code but also your UI elements. For this modularization, Apple provides an easy way to create a UI Controller and a XIB (neXt Interface Builder) in one.
Once you decided on a type of UI Controller (View, TableView, CollectionView, etc.), go into File > New > File (⌘N) and select Cocoa Touch Class
.
Anytime an iOS app requires some asynchronous data fetching, like API’s or database queries, we need a completion handler, telling us when the data is ready to use. Swift has a completion handler included, so in most cases, there is no need for any third-party libraries like PromiseKit. So let’s get started.
First, let’s look at a completion handler that returns nothing, except telling us, “It’s done”.
func querySomething(completion: @escaping () -> Void) {
//
//do something asynchronous (or synchronous, doesn't matter)
// completion()
}
So, do use this function, we call it (like we would any other):
querySomething(completion: {…
In apps, developers often require certain information at different points inside the app. To ask for this information, we need to generate a layover and trigger it from wherever in the application we are.
The input layover will consist of 3 main elements. A title, a subtitle, and the actual phone number input field (you can change this to any input field you require, the user's height, email address, etc.). To trigger the layover, we create two buttons to save the input and give the user the option to delay the information (Do it later).
First, we create ourselves a…
The Firebase SDK is an excellent adventure on iOS. Lot’s of different modules to choose from, lots of different functionality, and plenty of errors when building the modules. I’ve developed my one working strategy to query Firebase Firestore documents into my iOS Swift projects properly.
Before we start programming, we need the correct dependencies in our Podfile. Add these two dependencies to your Podfile and run pod install
.
pod 'Firebase/Firestore'
pod 'FirebaseFirestoreSwift'
The data model is the Struct representation of what the document looks like in your Firestore. …
Upfront, the Mac M1 (I am using the Macbook Pro) is a marvelous piece of engineering. Apple managed to compact a huge amount of performance and battery performance into a machine that starts at only $1299. The maxed-out iPhone 12 Pro costs more than that. And the iPad Pro with roughly the same screen size (but double the storage) costs the same.
Yes, the almighty but. I have now been working with my M1 for a few months, and it slowly but surely became my primary machine for work. Upfront: I am not writing about the excessive SSD writing (by…
My work consists of many things. While working on a project from scratch is great, most of the time I am finishing/fixing work for someone else, consulting on possible next steps, or reviewing the code for performance and security. I want to share the worst developer-inflicted security holes I have seen in the last couple of years with you. And, of course, while we are on it, show how I fixed and resolved them.
In pretty much all of the projects I open, at least 95% of the user data is stored in UserDefaults. When using UserDefaults in Android (called…
As a great start for getting into freelancing, Fiverr gives developers all over the world the chance to get paid for simple work and consulting. It is both a great way to earn some extra bucks (on your flexible schedule) and even make a living during a crisis. While finishing works on Fiverr, I learned some important life lessons I want to share with you today.
During the planning and execution process of development gigs, I learned how crucial it is to have perfect time management. When calculating the price for a gig (your earnings), you will primarily look at…
When browsing different articles and StackOverflow, it feels a lot harder to auto-detect any type of links in a TextView than it is.
We start by adding a UITextView to a storyboard like this. Align both horizontally and vertically.
Mobile application developer and health enthusiast from Hamburg