Skip to main content

SwiftUI String to Binding<String> error

After creating a new view with a @Binding string as follows

struct EditRival: View {

  @Environment(\.presentationMode) var presentationMode
  @EnvironmentObject var realmPerson: RealmPersons
  @Binding var uid: String

 

The previews struct had an error with the var previews

Validating email in Swift or SwiftUI

I'm currently working on a project that requires login, register, forget password functionality in SwiftUI.  As I'm developing the code, I came across a great resource for validating an email address with Regex:

http://emailregex.com/

Contact list showing known contacts and the contacts in my phone

Building a contact list using SwiftUI has many challenges.

One challenge is having multiple lists displayed on the one screen.  For example, known contacts using your app against contacts on the phone.  Initially, I tried the following code

Realm object with NSPredicate

What to do when you want to filter a Realm object, using NSPredicate in SwiftUI or in Swift.  

Applying the filter to a simple condition in one line

let exists = realm.objects(ExampleObj.self).filter(NSPredicate(format: "uid = %ld", uid))

Creating a variable predicate that will be injected as a condition

Uploading plist data to the server using an API

I had an instance where I needed to move content from a plist to the server database.  To achieve this step, I added a few lines of code where the plist was called and added a call to the API so the data would be on the server.

The original code appeared as:

Creating a new SwiftUI project

Creating a new SwiftUI project is a quick process.  There are already thousands of sites outlining how to do these steps.  Rather than repeat this steps at the top of each article, we will refer to this article to get you across the line if you don't know or need a refresher.

Step 1

Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project.

SwiftUI adding a background image with a gradient tint

I'm going to take you on a journey about adding a gradient tint to a background image.  The journey will go through text modifiers with regular and semibold font weights, and font colour.  Using an image from Unsplash.  Adding a black tint, then transform it to a gradient using a colour array.  If you get lost along the journey, the final result is available on GitHub.

How to programmatically change the app language without restarting the app

iOS localization on the fly

If you have added languages to your app... shortly afterwards you'll be getting yourself knee deep in changing the language on the fly.  Followed by the question – how do you change the language of the app without having to restart the app?  To change the language of the app there are a couple of key steps involved:

Subscribe to SwiftUI