Swift: Basic Syntax [Bools, Floats, and Doubles]

Bool Bool is the Boolean data type . A Boolean can only ever hold one of two states : true or false . Swift var isDarkModeEnabled : Bool = false isDarkModeEnabled . toggle () // Flips the state: false -> true let isAuthenticated : Bool = true let hasAdminPrivileges : Bool = false print ( "Is the user logged in? : \( isAuthenticated )" ) // true print ( "Does user have admin access? : \( hasAdminPrivileges )" ) // false Float and Double Float and Double are used to store real numbers featuring fractional decimal points — known in computer science as floating - point numbers . Swift offers two main variations : Double : Represents a 64 - bit floating - point number . Float : Represents a 32 - bit floating - point number . In a standard 64 - bit environment , a Double has a precision of at least 15 decimal places , whereas a Float maxes out at 6 decimal places . While ...

Swift: Basic Syntax [Multi-line Strings]

Standard strings in Swift open and close with double quotes, but they cannot contain actual line breaks (by hitting Enter). For example, here is a standard string: Swift var quote = "I will code hard and become a great developer." This works fine for short snippets of text, but if the text you want to store is long, it becomes ugly and hard to read in your source code. That is why we use multi - line strings. How to Use Multi - line Strings By using triple double quotes ( """), you can write a string across as many lines as you need. This makes the text much easier to read inside your codebase. Swift var harrtPotter = """ You ' re a wizard, Harry. I ' m a what? A wizard. And a thumping good one, I ' d wager. """ Because Swift treats the line breaks in your code as part of the text itself, the stored string actually contains thr...

Swift Basics: [Advanced - Functions] Default Parameters & Argument Labels

⚙️ Default Parameter Values A default parameter value allows a parameter to automatically assume a specific value if no argument is passed in when the function is called . To declare a default parameter , simply specify the type after the parameter name and assign the default value to it . Tip : It is highly recommended to place parameters with default values at the very end of your parameter list . Swift // Specify the type after the parameter name and assign the default value func functionName ( param1Name : Param1Type , param2Name : Param2Type = DefaultValue ...) -> ReturnType { // Function implementation return returnValue } Let ' s look at an example . Below , we ' ve set the default parameter value for me to "Jeamin" . Swift // A default value is assigned after the 'me: String' parameter type func greeting ( friend : String , me : String = "Jeamin...

Swift Basics: A Quick Comparison of Class, Struct, and Enum

🏛️ CLASS In Swift, we generally use the term instance instead of object. In other words, an instance of a class type is not strictly referred to as an object. Supports only single inheritance. Has (Instance / Type ) Methods and (Instance / Type ) Properties (same as Structs). It is a Reference Type . Most of the traditional iOS frameworks (like UIKit) are heavily composed of classes. (Note: In contrast, SwiftUI is predominantly composed of Structs.) 🧱 STRUCT Unlike Classes, inheritance is not possible. Has (Instance / Type ) Methods and (Instance / Type ) Properties (same as Classes). It is a Value Type . The core backbone of Swift ' s standard library is mostly made up of Structs. Basic data types like Int , Double , and String are actually Structs under the hood. 💡 When to use Structs: When you want to encapsulate a few related data values into a...

How to Set Up Fastlane for iOS

✅ 1. Prerequisites Required Tools macOS Xcode (Install via the App Store or Apple Developer site) CocoaPods (sudo gem install cocoapods) Ruby (Pre - installed on macOS) Node.js / npm React Native CLI (npm install - g react - native - cli or simply use npx react - native) ✅ 2. Installing Fastlane 1. Install Fastlane Bash sudo gem install fastlane - NV The - NV flag provides detailed installation logs. If you encounter issues, you can install it via Homebrew: brew install fastlane (Recommended: the Homebrew method keeps the installation isolated from your system). 📌 Note: When using brew install fastlane, Fastlane will use the Homebrew Ruby environment instead of the system Ruby. 2. Initialize Fastlane Navigate to your project ' s root or the ios / directory and run: Bash cd ios fastlane init 3. Select Initialization Options Fastlane will ask you the followi...

How to Add and Manage Git Remote Repositories

🔹 1. Adding a Remote Repository To add a new remote repository, use the following command: Bash git remote add <remote-name> <remote-url> Example: Bash git remote add origin https://github.com/user/repo.git 🔹 2. Checking Added Remote Repositories To view the list of currently added remote repositories, run: Bash git remote -v 🔹 3. Changing (Updating) a Remote Repository URL If you need to change the URL of an existing remote repository, use this command: Bash git remote set-url origin <new-url> Example: Bash git remote set-url origin https://github.com/newuser/newrepo.git 🔹 4. Removing a Remote Repository To remove a remote repository from your local Git tracking, use: Bash git remote remove <remote-name> Example: Bash git remote remove origin Now you are all set to add and manage your Git remote repositories! 🚀