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" ) { print ( "Hello \(friend) ! I am \(me) ." ) } Now let's call t...

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 single compound type. When you want the encapsulated data to be copied rather than referenced when passed to another function or assigned to ...

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 following question: "What would you like to use fastlane for?" Options: 📦 Automate beta distribution to TestFlight 🚀 Au...