Posts

Data Types In Swift

Data Types in Swift Swift is a statically typed language, meaning every variable and constant must have a specific type assigned to it. Here are some commonly used data types in Swift:   1. Integers (Int):   Represents whole numbers, both positive and negative.   Sizes: Int8, Int16, Int32, Int64 (platform-dependent).   Example: let age: Int = 30   2. Floating Point Numbers (Float and Double):   Represents numbers with fractional components.   Float: 32bit floating-point number.   Double: 64bit floating-point number, with higher precision than Float.   Example:     swift code   let pi: Float = 3.14   let gravity: Double = 9.81      3. Strings (String):   Represents a sequence of characters.   Enclosed in double quotes (").   Example: let name: String ...

Constants and Variables

Constants and Variables in Swift Constants (let):   Declared with let.   Immutable; value cannot change once initialised.   Ideal for values that remain constant throughout the program.   Promotes safety and clarity in code. Variables (var):   Declared with var.   Mutable; value can be changed after initialisation.   Suitable for values that may vary during program execution.   Provides flexibility in managing and updating data. Key Differences:   Constants ensure immutability, enhancing code safety.   Variables allow for value changes, offering flexibility in data management.

Swift syntax overview

Swift syntax is designed to be clear, concise, and expressive, aiming to enhance readability and developer productivity.   1. Variables and Constants: Variables are declared using var keyword, and constants are declared using let. Example:    swift code    var age = 24    let name = "@hiren_syl"     2. Type Annotations and Type Inference: Swift supports both explicit type annotations and type inference.    swift code    var score: Int = 100    var message = "Hello, World!" // type inferred as String     3. Optionals: Optionals represent the presence or absence of a value. They are declared by appending ? to the type.    swift code    var optionalName: String? = "John"     4. Basic Operators: Swift supports standard operators like arithmetic, comparison, and logical operators.    swift code    let sum = 5 + 3    let isGreater = 10 > 5   ...

Api Calling (Basic To Advance)

 What is Api Calling? API calling in a mobile app refers to the process of making requests to external Application Programming Interfaces (APIs) from within the mobile application. APIs act as a bridge between the mobile app and external data sources or services, allowing the app to access and integrate relevant information and functionalities. Api Calling in iOS/ Swift5 :- Basically we need this normal steps written below to perform Api call in iOS apps. 1. URL Construction :  -  Think of this step as setting the destination for your data request. You need to know exactly where you want to send your request. This involves creating a URL that points to the API endpoint.    - Create a `URL` object that represents the API endpoint you want to access.    - Construct the URL by combining the base URL of the API and any necessary query parameters or path components. 2. URL Request Creation:    - Create a `URLRequest` object to encapsulate the deta...