Posts

What is the use of Link in SwiftUi?

Image
 - : Swift UI :- Link in SwiftUI :- Open the link which you want to open in browser ex: www.google.com Code Example :           Link(“Go to google”, destination: URL(string:“ www.google.com ”))   Link("Go to Google", destination: URL(string: "https://www.google.com")!)                  .buttonStyle(.borderedProminent)                  .buttonBorderShape(.capsule)                  .controlSize(.large)                  .tint(.green.opacity(1.5))                        Link("Go to Apple", destination: URL(string: "https://apple.com")!)                  .buttonStyle(.plain)                  .buttonBorderShape(.capsule)  ...

What is SwiftUI? and what is the use of swiftUI?

Image
- : SwiftUI : -  SwiftUI is a user interface toolkit that lets us design apps in a declarative way. That’s a fancy way of saying that we tell SwiftUI how we want our user interface to look and work, and it figures out how to make that happen as the user interacts with it. Declarative UI is best understood in comparison to imperative UI, which is what iOS developers were doing before iOS 13. In an imperative user interface we might make a function be called when a button was clicked, and inside the function we’d read a value and show a label – we regularly modify the way the user interface looks and works based on what’s happening. Imperative UI causes all sorts of problems, most of which revolve around state , which is another fancy term meaning “values we store in our code.” We need to track what state our code is in, and make sure our user interface correctly reflects that state. If we have one screen with one Boolean property that affects the UI, we have two states: the Boolean ...

Dictionaries In Swift

Image
 What’s a Dictionary?                     You can use a dictionary to store a collection of key-value information in your app. A dictionary is similar to an array in the sense that both store lists, also called collections, of items of the same type.                     A dictionary is a fundamental collection in Swift programming. With a dictionary you can store key-value data in your app. It’s a collection type, similar to array and sets, but completely different too. Let's see an example:- Here’s an example of a dictionary:                               The type of the scores dictionary is [String: Int]. That means that the type of the keys in the dictionary is String, and the type of its values is Int.    In the above example we haven’t explicitly provided the t...

Arrays in Swift Programming Language

Image
 Array In Swift Arrays are fundamental building blocks of apps.                      In computer programming, arrays are numbered lists (or “collections”) of items with the same type. A variable contains one value, and an array can hold many values. Let’s get started with the syntax to create an array.                     Swift arrays are applied for storing multiple values in ordered lists of any specific type. Swift set up strict checking mechanism which does not allow programmers to enter or insert any wrong type in an array even by mistake, i.e., arrays in swift programming are specific about the kinds of values they can store. The same value can appear in an array multiple times at different positions.  Shorthand syntax of arrays:                     The swift array can also be written in t...

Set Collection in swift

Image
  Sets In Swift                     A set stores distinct values of the same type in a collection with no defined ordering. You can use a set instead of an array when the order of items isn’t important, or when you need to ensure that an item only appears once. NOTE Swift’s Set type is bridged to Foundation’s NSSet class. For more information about using Set with Foundation and Cocoa, see Bridging Between Set and NSSet. Hash Values for Set Types :                     A type must be hashable in order to be stored in a set—that is, the type must provide a way to compute a hash value for itself. A hash value is an Int value that’s the same for all objects that compare equally, such that if a == b, the hash value of a is equal to the hash value of b.                     All of Swift’s basic types (such as Str...

Loop in Swift programming Language

Image
Concept of Loop in Swift Looping :-                     Looping, also known iteration is used in a program to repeat a specific block/segment of code(s). This reduces the tasks of writing the same thing again and again.  for condition increment loops:-                     The for-condition-increment loop is functionally the same as the 'for' loop in C. The loop consists of an initialization phase, a test, an increment, and a set of statements that are executed for every iteration of the loop. for initialization; condition; increment { statements } for in loops:-                      You use the for-in loop to iterate over sequences or collections of things, such as the elements of an array or dictionary, the characters in a string, or a range of numbers. Here's the general form is: for index in seque...

If Else In Swift Programming Language

Image
 IF ELSE IN SWIFT:-                     An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement. When using if, else if, else statements, there are a few points to keep in mind:- An if can have zero or one else's and it must come after any else if's. An if can have zero to many else if's and they must come before the else. Once an else if succeeds, none of the remaining else if's or else's will be tested. The Swift if-else statement contains two statements:  if statement and  else statement. example: Output:- This is a positive number. This will be executed anyways.                     In swift, if else-if else statement is used to add alternative set of multiple else-if and single else statements for if condition. In case if condition fails (FALSE) then ...