Swift Helper Article Part 1

Solutions To Real-World Problems in Swift

Yasir
TheLeanProgrammer
2 min readMay 19, 2021

--

This article contains solutions to the few common problems you will face later or early in your carrier 👀 .

If you are an iOS Developer, you are going to face these questions in the future or you may have faced these questions already. Just read this article and implement its usage in your real-world applications 👍🏻

Now let us look at the first question!

How to compare two Date type variables in Swift?

Suppose you are working on an application that shows the DATA of the selected date in a calendar. Now to compare the date in the calendar with the date in your DATA is what we are going to see here.

The above code of snippet solves the problem. 🔥

How to Pass a Unix Time in Date type variable in Swift?

Today’s date is: 19 May — 2021

Now, visit this link which converts the date to timestamp. Copy today's timestamp.

Now if you print the today, you will get today's date, if you want to store some others dates, you can copy the timestamp and store it in your variable.

Email Validation in Swift?

This is the function that will return true if the email passed is valid and false otherwise.

How to know if a password string contains any special characters in Swift?

The below predicate will solve this problem.

Thanks for Reading 👏🏻

Reach me on: LinkedInGitHub

Check this link: https://bit.ly/38HOQeb

Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter tinyletter.com/TheLeanProgrammer

--

--

Yasir
TheLeanProgrammer

Exploring the Swift, SwiftUI, and Apple universe.