All Blogs

Protocol Composition in SwiftSwift

Protocol Composition in Swift

In Swift, protocol composition is a powerful feature that allows you to combine multiple protocols into a single name. This can be very useful when you want to define a type that needs to adhere to multiple protocols simultaneously. Instead of writing multiple protocols again and again, you can just give a single name by combining them. In this article, you will learn about: * Protocol Composition without typealias * Protocol Composition with typealias * Using Composition in Functions * Pr

September 4, 2023

Practical Guide to Protocol Extensions in SwiftSwift

Practical Guide to Protocol Extensions in Swift

Protocol Extensions allow you to add default implementations and computed properties to protocols. This mean, when a type conforms to a protocol, it automatically gains the functionalities provided by the protocol extension. In this article, you will learn about:

August 29, 2023

Secure iOS Application with SSL Pinning | Man in the Middle AttackSwift

Secure iOS Application with SSL Pinning | Man in the Middle Attack

SSL Pinning is a technique where we introduce a certificate between application and server so our connection is secure. Although iOS checks for a valid certificate from its trust store while making connection to server.

August 18, 2023

Protocol Oriented Programming in SwiftSwift

Protocol Oriented Programming in Swift

This article will dive deep into Protocol-Oriented Programming in Swift, exploring advanced techniques and real-world examples.

August 16, 2023

Top 10 iOS Interview QuestionsInterview

Top 10 iOS Interview Questions

We have listed down 10 must know iOS Interview Questions that will help an iOS developer prepare for the interviews.

June 7, 2023

ProgressView in SwiftUISwiftUI

ProgressView in SwiftUI

Almost everyone hates the buffering screen we get due to low internet or the app processing something. Well, but since 5G is here in India, there are less chances of you spending your day just staring at a progress view. Even though we all hate it, making a progress view in your app is inevitable and at some point, you would have to use it in our app. May it be for showing process while you save something to CoreData or to show progress while you are getting something from URLSession. Looking

December 24, 2022

Sets in SwiftSwift

Sets in Swift

You may have come across the concept of Arrays and Dictionaries, two primitive types of collecting and storing the values, but there is a third one in the group called Sets. These three types are together referred to as Collection Types. If you're unfamiliar with Arrays and Dictionaries, we strongly suggest reading up on those concepts before continuing with this one. What makes Sets different from Arrays/Dictionaries? What are Sets? Sets are unsorted collections that contain unique values.

December 10, 2022

Swift Anytime Bangalore Meetup

Swift Anytime Bangalore Meetup

The Swift Anytime Bangalore Meet-up was an exciting event that brought together an enthusiastic group of iOS developers from all over India. Held in December, 2022, this event was the perfect opportunity for like-minded professionals to share ideas, network, and learn from one another. The event kicked off with a fun and informative introduction by the Co-founders of Swift Anytime, who explained the organisation's mission and goals. Attendees were then treated to a fast-paced quiz session that

December 9, 2022

Understand UIResponder & Responder Chain to Handle EventsUIKit

Understand UIResponder & Responder Chain to Handle Events

In this article, you will learn how to handle events that communicate through the app. What is UIResponder? This is an abstract interface for responding to and handling events. An abstract interface is just combination of properties and methods to override them only. You can say, all the instances of UIResponder (responder objects) are the backbone of iOS apps. Here are some responder objects that are most commonly used: * UIView * UIViewController * UIControl * UIApplication Note: You w

December 6, 2022

How to access private members of a class in SwiftInterview

How to access private members of a class in Swift

This article will show you how to access a class's private members, such as variables and methods in Swift. In the normal case, you cannot access private members outside the scope of a class directly, but let's see what are the alternative ways to access members within and outside the scope of a class. What is the Private Access Control? In Swift, private is an access control used to define how types, functions, and other declarations can be accessed in your project. You can set the private

December 3, 2022

What is Trailing closure in Swift?Interview

What is Trailing closure in Swift?

As per the standard definition, Closures are self-contained blocks of functionality that can be passed around and used in your code. When passing a closure expression to a function as the function’s final argument, it can be useful to write a trailing closure. Trailing closure is written after the function call’s parentheses even though it is still an argument to the function. When you use the trailing closure syntax, you don’t write the argument label for the closure as part of the function c

November 29, 2022

Toggle in SwiftUISwiftUI

Toggle in SwiftUI

Toggles are some of the most used UIControl in iOS Apps since it lets let you switch between a binary state - true or false, 0 or 1. You are most likely to encounter a toggle in settings or some kind of list view. But regardless of your app has settings or not, it doesn't hurt to learn about Toggle in SwiftUI. Before diving into a toggle, let's take a look at Human Interface Guideline. Note: This is UIKit equivalent of UISwitch Takeaways from Human Interface Guideline * Recommended to use

November 26, 2022

How to use Gestures In SwiftUISwiftUI

How to use Gestures In SwiftUI

Back when we had Blackberry and Nokia phones, everything was based on button clicks. After clicking those chunky keys, you would be able to write the text and use the phone. Got some nostalgia kicking in, huh? Well, that was the scenario back then. When the touch screen phone came, all those chunky keys were gone and everything was based on finger gestures. There are multiple gestures one can perform on a modern cell phone: tap, drag, swipe, pinch, double-tap, rotate, shake, touch and hold, and

November 16, 2022

View Controller LifecycleInterview

View Controller Lifecycle

Introduction In iOS development, the view controllers are the foundation of the Application's internal structure. The View Controller is the parent of all the views present on a storyboard. Each UIKit application has at least one ViewController. It facilitates the transition between various parts of the user interface. Functions are called in the following order when a View Controller is added to the view hierarchy: Join our Slack community now! State Transition Functions viewDidLoad()

October 20, 2022

How to dismiss the keyboard in SwiftUISwiftUI

How to dismiss the keyboard in SwiftUI

When dealing with forms and more, it is likely that you would encounter a scenario where you would want to dismiss the keyboard programmatically ie. on click of "Submit" or "Next" button. Without further ado, let's explore a couple of ways to dismiss the keyboard in SwiftUI. Using App Delegate Methods One of the easiest way is to use app delegate method and calling the endEditing() on UIApplication. This method will resign the first responder of the view (which, in this case, is the textfield'

October 18, 2022

Action Sheets in SwiftUISwiftUI

Action Sheets in SwiftUI

Action Sheets allow you to show a popover over the current view presenting the user with certain options to select. In SwiftUI, you can implement action sheets using .actionSheet view modifier. You can observe the usage of action sheets through iOS, specially in events while confirming actions. So without further ado, let's dive in and explore about action sheets. But before that, it is important to follow right practices, so let's look into what Apple's Human Interface Guideline says. Best P

October 14, 2022

Links in SwiftUISwiftUI

Links in SwiftUI

In Apps, there are many scenarios where you want to open a link, the link can be a web link, a link to an external app like mail, or phone, or any deep link. In this article, we will be take a look at Link API provided by SwiftUI to handle a different kind of links. Links Links that directly open in the default web browser or external apps can be made using Link(). For example's sake, let's try a Link with text inits along with a destination URL. struct ContentView: View { var body: some

October 11, 2022

Swift native base class NSObjectUIKit

Swift native base class NSObject

Description The root class of most Objective-C class hierarchies, from which subclasses inherit a basic interface to the runtime system and the ability to behave as Objective-C objects. It's the one class that has no superclass. Core Responsibility: The NSObject class provides inheriting classes with a framework for creating, initializing, deallocating, copying, comparing, archiving, and unarchiving objects, run-time environment, querying objects, and message forwarding. > The NSObject is an a

October 6, 2022

Top 5 open source iOS Repositories to start with this Hacktoberfest 2022Hacktoberfest

Top 5 open source iOS Repositories to start with this Hacktoberfest 2022

Just like how people wait for December for the Christmas vibe and ritual the whole year, developers wait for October for the Hacktoberfest. Now you ask what is Hacktoberfest and why should one participate in it? Hacktoberfest is a month long running event organised by Digital Ocean for encouraging open sourcing, many of the third party pods/dependencies that we use in our day to day development, are open sourced and handled by folks around the community, as you heavily rely on this open source

October 5, 2022

Full Sheets In SwiftUISwiftUI

Full Sheets In SwiftUI

Full Sheets are used extensively in SwiftUI for presenting views. They are almost similar to sheets. If this were UIKit, you would code something like: var controller = ViewController() controller.modalPresentationStyle = .fullScreen self.present(controller, animated: true) But since this is SwiftUI, we use a view modifier command. For full sheets, there are not a lot of parameters you could play around with. We are going to explore the two commands that you are most likely to encounter in

September 30, 2022

UIView Fundamentals MasterclassUIKit

UIView Fundamentals Masterclass

In this article, you will learn about the basics of UIView. In addition, you will learn the purpose of UIView and initialization and implementation of UIView along with some practical examples. Also, how view create an hierarchy tree to render it on superview. Let's start. Basically, UIView is a container in iOS apps to create the user interface. You can have N number of views inside a view to build different kinds of user interfaces. Declaration: class UIView: UIResponder { } A view

September 29, 2022

Sheets In SwiftUISwiftUI

Sheets In SwiftUI

Sheets are used extensively in SwiftUI for presenting views. If this were UIKit, you would use a command like self.present(ViewController(), animated: true) but in SwiftUI, we use a view modifier command. For sheets, they are not a lot of parameters you could play around with. We are going to explore the two commands that you are most likely to encounter in practical development today. So without further ado, let's dive in. Basic Implementation All you need to implement a sheet is a state

September 27, 2022

Optionals and Unwrapping in SwiftInterview

Optionals and Unwrapping in Swift

An Optional is a type of its own that can handle the absence of a value. Optionals can contain nil values and there are multiple ways to unwrap them. In this article, we will understand why not to unwrap them forcefully and how to unwrap them safely. Optionals > A type that represents either a wrapped value or nil, the absence of a value. Some examples of optionals are: /* Optional types either contain a value or nil. It can be defined as Optional<type>. type? like Int? is syntatical su

September 22, 2022

Picker In SwiftUISwiftUI

Picker In SwiftUI

Pickers are control elements which let you pick a value from a list of mutually exclusive arrays. You can use it in forms or for selecting normal data. Human Interface Guidelines Summary Before diving into coding, let's take a look at Human Interface Guidelines summary. * Consider this when using medium-to-long list of items. * Use predictable and logically ordered value. * Consider showing it as a popover or a bottom sheet rather than switching views. Source: Apple Developer Basic Imp

September 20, 2022

Get started with WeatherKitWWDC

Get started with WeatherKit

This year, we received a package of surprises from Apple at WWDC22. Out of these exciting announcements, we got a new framework entirely focused on fetching weather data to your app or website called "WeatherKit." We will go through the step-by-step process of importing this framework and covering its basic requirements and usage. Why use WeatherKit? There are a bunch of reasons for using WeatherKit: * Powered by Apple Weather Service. * Easy to implement in your Xcode project, supports

September 15, 2022

How to delete derived data in XcodeXcode

How to delete derived data in Xcode

Xcode stores intermediate build results, generated indexes and other built results in form of derived data. It can grows to 5-10 GBs or even more depending on how complex your projects are. Sometimes, derived data can result into strange Xcode errors. That's why it is highly recommendable to delete the derived data. Also, note here that it is totally alright to delete the derived data (there are few consequences described in next paragraph). You won’t lose any your app data if you delete the de

September 13, 2022

Access Control in SwiftSwift

Access Control in Swift

This guide will explain how to make your code more or less accessible by using Swift's access controls. Basically, access controls in swift are used to define how types, functions, and other declarations can be accessed in your project. You can set the accessibility (visibility) of classes, structs, enums, functions, variables, and so on. Swift provides a variety of access controls that can be used for different purposes. These are: * Open * Public * Internal * Fileprivate * Private Di

September 7, 2022

Add Custom Themes in XcodeXcode

Add Custom Themes in Xcode

As an iOS Developer, Xcode is something you work with for over 8 hours a day or even more. Wouldn't it be cool to have your unique Xcode theme to make your life a little more exciting? Let’s see how you can add more themes to Xcode Finding Xcode themes A simple search with query "Xcode Themes" will reveal several Xcode themes for you to pick and choose. Go ahead and download the repo of the theme you like. Xcode themes mentioned: * Dracula * Charmed Dark Xcode theme * Sundell's Colors

September 6, 2022

ContextMenu in SwiftUISwiftUI

ContextMenu in SwiftUI

Context menus are basically peek-and-pop interactions and can be a great add-on to the UI elements in your app and can enhance the experience. Context menus works pretty much like Menus in SwiftUI. An analogy you could use is that context menu and menus are cousins. You will observe how Apple uses context menus consistently throughout their apps. Human Interface guidelines: The key takeaways from the human interface guideline for the context menus are: 1. Use submenus to manage complexity

August 24, 2022

For loop in SwiftSwift

For loop in Swift

In this guide, you will learn about For Loop in Swift. We will see many examples of how to use for-loop over collections and ranges. Looping means repeating an action over and over again. In Swift, there are some control flow statements that are used to control the execution flow of code. Some of them (like for-loop and repeat-while) are used to perform repeating tasks. For-Loops are used to repeat a task following a termination condition. For loop Usage For loop is a well-known statement f

August 18, 2022

How to convert Radians to Degrees in Swift?Swift

How to convert Radians to Degrees in Swift?

When working with rotating view animations or 2d/3d games, you would have to eventually deal with degrees and radians at some point. There are rare scenerios where you would have to convert radians to degrees since most of the angles are dealt in radians in Swift. But there is no harm to take a look, right? Before diving into the coding path, let’s get the math part clear. 1 pi radian = 180 degrees Note: pi = 3.14 Thus, for converting radians to degrees, you have to multiply it by 180  and

August 16, 2022

How to convert Degrees to Radians in Swift?Swift

How to convert Degrees to Radians in Swift?

When working with rotating view animations or 2d/3d games, you would have to eventually deal with degrees and radians at some point. Even though, most people have a better understanding of degrees over radians, most of the angles are dealt in radians in Swift [and general math as a matter of fact]. Before diving into the coding path, let’s get the math part clear. 1 pi radian = 180 degrees > Note: pi = 3.14 Thus, for converting degrees to radians, you have to multiply it by pi and divide by

August 9, 2022

Segmented Control in SwiftUISwiftUI

Segmented Control in SwiftUI

Segmented controls can be observed in social media apps - like in Twitter profile or Instagram profile view. If there were UIKit, we would use UISegmentedControl, but since it's SwiftUI, we used Picker with a specific picker style. So without further ado, let's dive straight into it. But before that, let's take a quick look at the human interface guidelines. Human Interface Guideline Summary Some takeaways from Human Interface Guideline: * Limit the number of segments and try to be consiste

August 6, 2022

Ultimate guide on Timer in SwiftSwift

Ultimate guide on Timer in Swift

A timer is a class used to perform any task after a specific time interval. Timers are super handy in Swift for scheduling tasks with a delay or scheduling repeating work. In this article, we are going to cover the following things: * How to schedule tasks? * Repeating and non-repeating timers * Using RunLoop modes * Keep track of timer * Timer optimisation to reduce energy and power impact class Timer : NSObject Why Timers are required? You often face requirements where you need to p

August 1, 2022

Slider in SwiftUISwiftUI

Slider in SwiftUI

Sliders are a replacement of UISlider from UIKit. You could observe the use of slider mostly in forms where one has to value from a big range. In the case you are looking forward to use this, let's dive into slider. But before that, let's learn about the key take aways from Human Interface Guidelines. HIG: * Work on the slider such that it matches the your app's theme. Add minimum value and maximum value tag. Source Slider Terminologies Let's take a look at a picture that describes all t

July 28, 2022

Dictionaries in SwiftSwift

Dictionaries in Swift

This tutorial assumes that you know the concept of an Array in Swift []. Dictionaries are nothing other than the advanced layer of an Array! If you want to store information about students going to the school like their Name, Surname, ID, Grades, and Address, keeping it as an array is a good idea, but what if some information is missing. For example, a student is not graded yet, and to find out things like that makes it difficult for you to figure ou

July 26, 2022

The Ternary Operator in SwiftSwift

The Ternary Operator in Swift

In Swift, we often use if-else statements to perform some conditional operations. In some cases, we can use ternary operator instead of if-else to write more readable code. To understand how the ternary operator works, let's examine its syntax. In order to understand ternary operators, we assume you are familiar with if-else statements []. Ternary Operator Syntax: condition ? expression1 : expression2 In syntax, If condition == tr

July 21, 2022

How to use VideoPlayer in SwiftUISwiftUI

How to use VideoPlayer in SwiftUI

With iOS 14, Apple introduced a native way for implementing video playback in your SwiftUI app. The VideoPlayer component in AVKit provides with this capability. So without further ado, let's dive in. Basic Implementation Let's try to play some local media. Firstly, you would need to import some media in Assets folder or in the project folder itself. Now that you have imported the media, let's play it using Video Player - player initializer. import SwiftUI import AVKit // 1 struct Conte

July 19, 2022

How to generate random number in SwiftSwift

How to generate random number in Swift

There are many times when you need to generate random values in your iOS apps such as: * Simulating dice rolls. * Shuffling playing cards. * Creating unique ID for a user. * Random object from an array. In Swift 4.2, there are new, simple and secure ways to generate random values. Before that, there was a random function written in C language. Today, you'll learn about the random() function that takes a range of values and as an output it returns a randomly picked value every time. Let's

July 14, 2022

AsyncImage in SwiftUISwiftUI

AsyncImage in SwiftUI

Almost all the modern apps and websites are driven by images and videos. The images you see on shopping apps, social media and entertainment apps are all loaded from some backend source. Since there are a lot of backend calls needed for this, if you actually waiting for all those images to load before showing the website, it would take immense amount of time to load the apps - which would result in bad user experience. A very simple but efficient solution for that is loading the image asynchron

July 12, 2022

SwiftUI 4 TextField, ShareLink & Presentation DetentsSwiftUI

SwiftUI 4 TextField, ShareLink & Presentation Detents

Now that you have explored about new color gradients, SF symbol rendering modes, variable colors and more in the Part 1, let's talk about native half sheet presentation, share sheet links and new modifiers in TextField. So without further ado, let's dive in. Presentation Detents Before SwiftUI 4, for implementing half sheet presentation, one would usually have to go some hack and implement UIViewRepresentable since there was no native way to do it in SwiftUI. But this year they introduced pre

June 28, 2022

What's new in SwiftUI Colors and SF Symbols? ft. WWDC'22WWDC

What's new in SwiftUI Colors and SF Symbols? ft. WWDC'22

SwiftUI was launched in 2019 and since then Apple has been constantly adding features and updates to make it production ready. Following that, there were drastic amount of updates made in SwiftUI 4. So, without further ado, let's dive into new updates on colors, styles and SF symbol implementation.​ 💡You can download the new SF Symbols from here []. Gradient Colors Before diving into gradient colors, let's get some context on foreground and backgroun

June 18, 2022

What's new in M2 MacBooks? ft. WWDC'22WWDC

What's new in M2 MacBooks? ft. WWDC'22

This year's WWDC includes significant upgrades to hardware (chipset) and software (iOS 16, macOS Ventura). Apple introduced their next generation of Apple Silicon M2 which they are shipping into their newly redesigned MacBook Air and the previous 13-inch MacBook Pro. So without further ado, let's dive into the specs. Source: Apple Source: Apple Let's check out how the new chipset differs from the previous generation. M1 ChipM2 ChipStarting Price999 USD (MacBook Air 2020)1199 USD (MacBo

June 15, 2022

What's new in Apple's iOS 16? ft. WWDC'22WWDC

What's new in Apple's iOS 16? ft. WWDC'22

It's that time of the year! Apple revealed iOS 16 this Monday in its keynote event at WWDC22. > “iOS 16 is a big release with updates that will change the way you experience iPhone,” said Craig Federighi, Apple’s Senior Vice President of Software Engineering. Here's everything you need to know: Features Your Lock Screen, but reimagined! iOS 16 has delivered the biggest update ever to your Lock Screen. Source: Apple * Personalize your Lock Screen the way you like it using a set of custom fon

June 8, 2022

Apple WWDC 2022 Keynote RecapWWDC

Apple WWDC 2022 Keynote Recap

The year's most exciting week for developers began yesterday, or as most of us like to say - it's Christmas for developers. Apple kicked off Day 1 of the Worldwide Developers Conference 2022 (WWDC) with a jam-packed Keynote. From new software reveals to futuristic hardware announcements, here's a recap of everything announced on Monday.​ iOS 16 & iPadOS 16 iOS 16 offers new intelligence, sharing, and communication features that will change the way you use your iPhones.​ * You can now custom

June 7, 2022

How to implement Apple's SharePlay? WWDC'22SharePlay

How to implement Apple's SharePlay? WWDC'22

With the launch of iOS 15 (in June 2021), Apple launched a new feature which allows you to experience content together with other people on a FaceTime call. Integrating SharePlay to your applications is really straightforward once you understand how the objects work and when the methods should be triggered. So, without further ado, let's dive straight into the fundamentals. Prerequisites * Developer account * Two devices to test it on Note: If not possible, you can implement catalyst in y

June 7, 2022

How to use Geometry Reader in SwiftUISwiftUI

How to use Geometry Reader in SwiftUI

SwiftUI Layout works very differently than UIKit; Wherein UIKit we dealt with raw frames, and either added constraints accordingly or have some concrete frame-set to specify the position of views, in SwiftUI, the layouts are defined in form of stacks, spacers and paddings. This layout system provides us a lot of simple and flexible ways to define our view's position, but sometimes scenarios arise where you need to have specific frames or size set for a view either by setting some concrete value

June 4, 2022

Visual Effects in SwiftUISwiftUI

Visual Effects in SwiftUI

Swift provides with different ways of displaying visual effects like blur and vibrancy effects. These can mostly be used as background for views and can be used to improve the overall app design. You can observe these blur effects throughout iOS like in app library, control center and app dock. Materials Adding visual effect as background in iOS 15 is as easy as doing the following: Text("Hello, World!") .frame(width: 200, height: 50) .background(.thickMaterial) No

May 24, 2022

Swift if else, switch case Conditional StatementsSwift

Swift if else, switch case Conditional Statements

To put it simply, a group of codes, when executed on a particular/certain conditions, are known as conditional statements. You can quickly identify them by figuring out some noticeable terms like if, if ...else, switch case. Generally, developers use it when needed to execute the code on a particular condition, and that could be any like, for example, * if the value is more significant, lower, or equal to * if the specified condition is true/false, etc. Read and go over the detailed explanat

May 18, 2022

Variables in SwiftSwift

Variables in Swift

What are variables? Most of you are here to understand the first and foremost concept of programming, but we will help you answer with the simple steps: If you were attentive and loved Maths as your subject in High School, it's easy to identify this concept quickly. Never mind, forget that Math Class from your boring instructor. We are here to explain it in an easy way. For that, speak out the word variable. Does it sound somewhere close to the word "Vary", well now we assume you know the meani

May 17, 2022

Arrays in SwiftSwift

Arrays in Swift

Till now, what you saw is assigning only one value to a variable/constant. You might have one question though, what if I have a bunch of values to store? Answer to that question is quite straight forward, to store the collection of Hot wheels, we keep it in a rectangle or square box. Just like that, if you want to store a collection of items in one variable, an array helps there. Arrays can be defined as a collection of same type of values in an ordered position. Let's first have a look at the

May 12, 2022

Colors and Gradient in SwiftUISwiftUI

Colors and Gradient in SwiftUI

Colors are powerful. They can convey a message by the visuals and can give a certain kind of vibe to the art (for us, the app). It is one of those inevitable things that you are going to encounter while making pixel perfect production app. So, without further ado, let's dive into colors in SwiftUI. Usage The primary usage that most developers encounter first in SwiftUI App Development is as for adding background and color to the view. Let's look into an example: VStack { Text("

May 11, 2022

Are Arrays thread-safe in Swift?Interview

Are Arrays thread-safe in Swift?

Introduction An array is an ordered, random-access generic collection. The Array type to hold elements of a single type, the array’s Element type. An array can store any kind of elements—from integers to strings to classes. Are Arrays Thread-Safe? Intrinsically, Arrays in Swift are not thread-safe. Arrays are 'value-typed' in the effect of assignment, initialization, and argument passing — creates an independent instance with its own unique copy of its data. Immutable arrays (declared using

May 1, 2022

Functions in SwiftSwift

Functions in Swift

The function is a set of commands/statements. To create a simple function, you first have to define and name it; generally, naming is according to the task you want it to perform. For example: var age = 18 let name = "Krishna" print("Hi, I am " + "\(name)") print("I am " + "\(age)") The set of commands you see above may be needed more than once for the XYZ project, and programmers make work easy for people, including them. To use the same code every time, the concept of function is essential

May 1, 2022

What are Constants in Swift?Swift

What are Constants in Swift?

This tutorial assumes that you know how to declare a variable and to work with data types. Well, almost everything is similar between constants and variables, except for two things. If you store a value in constant, it will stay the same throughout the whole program, unlike variables and the grammar (in terms of programming, we call it Syntax). Talking about syntax, then they pretty much have the same format. The only difference is changing the var keyword with let. For example: var x = 45 //V

May 1, 2022

Difference between Array and NSArrayInterview

Difference between Array and NSArray

Array and NSArray are very similar and core constructs in iOS Development, and cause of this similarities we sometime forget how different this two construct works, these are some major difference that you must know about Array and NSArray. Array Array is a struct which means it is value type in Swift. var arr = ["Taylor", "Swift", "Taylor's", "Version"] func modifyArr(a : Array<String>) { a[2] = "Not Taylor's" } modifyArr(arr) print(arr) /* This prints - ["Taylor", "Swift", "Taylor'

April 27, 2022

What is inout Parameter in Swift?Swift

What is inout Parameter in Swift?

By default, function parameters are constants/non-mutable and if you try to change the value of a function parameter from within the body of that function, it results in a compile-time error. Therefore, if you want a function to modify a parameter’s value, and you want those changes to persist after the function call has ended, define that parameter as an in-out parameter instead. Well, it's time to take an example; var number = 6 func doubleNumber(num: Int) -> Int { return num * 2 } pri

April 26, 2022