Swift Tutorial
Welcome to Swift Tutorial. In this series of Swift Tutorials, you will learn all the basics of Swift programming language with detailed examples.
Introduction to Swift
- Swift is a new programming language developed by Apple Inc.
- Swift is used to develop applications for iOS and OS X.
Pre-requisites for Swift Tutorial
This Swift Tutorial is targeted for beginners. So, every topic shall be explained in detail. You will find it better if you know basic programming concepts or any other programming language.
Swift Tutorials
In this Swift Tutorial series, we shall go through the following topics.
Get Started
Create a Swift Project (Command Line Tool) in Xcode
Swift Basic Tutorials
These basic Swift Tutorials gets you introduced with the datatypes available in Swift, how to declare variables, constants, etc, what are the keywords available in swift, and operators like logical, arithmetic, boolean, etc.
Variables
How to create an Integer variable in Swift?
How to create a String variable in Swift?
How to get Type of variable in Swift?
Swift Datatypes
The following Swift Tutorials deal with each of the datatype in Swift separately with examples.
Swift Operators
The following Swift Tutorials deal with each of the operator in Swift separately with examples.
Swift Decision Making Tutorials
The decision making statements are those that execute a block of statements based on the evaluation of an expression (or condition).
Swift Loops Tutorials
Looping statements help to execute a set of statements repeatedly based on the evaluation of a condition. Also, there are loop control statements like break and continue to break a loop abruptly and continue with the other statements or skip the execution of statements for an iteration.
Swift Keywords
Swift Input-Output
Swift – Read User Input from Console
Swift – Read Number from Console
Swift – Print to Console Output
Swift Printing
Swift – Print without New Line
Swift – Print Multiple Strings with a Specific Separator
Swift Strings Tutorials
Strings are the basic data types that one uses for most of the real-time applications. Following series of Swift Tutorials help you on how to work with Strings in Swift, how to find the length of a string, how to check if two strings are equal, how to convert a string to integer or vice-versa, and other useful string operations.
Swift Array Tutorials
Arrays store like kind of elements in a sequential manner and can be accessed using a single variable name and of-course the index. Following Swift Tutorials deal with how to work with Arrays in Swift, starting from initialization and proceeding with different operations like printing, checking, appending, removing elements from the array.
Swift Set Tutorials
Sets are collection of items that are stored not necessarily in sequential manner.
Swift Dictionary Tutorials
Other Useful Swift Tutorials
Swift Error Handling
Swift error: return from initializer without initializing all stored properties
Swift – struct error: missing argument labels in call
Swift Programs
Mathematical Programs
- Swift – Calculate the factorial of a number
- Swift – Swap two numbers
- Swift – Generate a random number
- Swift – Check if a number is a palindrome
- Swift – Find the Greatest Common Divisor (GCD)
- Swift – Find the Least Common Multiple (LCM)
- Swift – Check Prime Number
- Swift – Generate a Fibonacci Series up to a Given Number
- Swift – Calculate the Power of a Number using Recursion
- Swift – Count the Number of Digits in an Integer
- Swift – Reverse an Integer
- Swift – Check Armstrong Number
- Swift – Find the Sum of Digits of a Number
- Swift – Check Perfect Number
- Swift – Calculate Simple Interest
- Swift – Calculate Compound Interest
- Swift – Check Strong Number
Recursion-Based Programs
- Swift – Calculate Factorial using Recursion
- Swift – Generate Nth Fibonacci Number using Recursion
- Swift – Tower of Hanoi
- Swift – Find Greatest Common Divisor (GCD) using Recursion
- Swift – Reverse String using Recursion
- Swift – Count Number of Digits in an Integer using Recursion
- Swift – Find Sum of Digits of a Number using Recursion
- Swift – Generate all Subsets of a Set using Recursion
- Swift – Solve the N-Queens Problem using Recursion
- Swift – Find Permutations of a String using Recursion
Logical and Algorithmic Programs
- Swift – Check Leap Year
- Swift – Print Multiplication Table of a Number
- Swift – Find the Largest of Three Numbers
- Swift – Implement a Basic Calculator (Add, Subtract, Multiply, Divide)
- Swift – Generate Pascal’s triangle
- Swift – Count the number of prime numbers in a range
- Swift – Check if two numbers are co-prime
- Swift – Implement a binary search algorithm
- Swift – Find the square root of a number without using a library
Data Structure Programs
- Swift – Implement a stack (push, pop, peek)
- Swift – Implement a queue (enqueue, dequeue)
- Check if parentheses are balanced in an expression
- Find the maximum element in a stack
- Implement a linked list (add, delete, traverse)
- Reverse a linked list
- Implement a binary tree (add, search, traverse)
- Implement depth-first and breadth-first search
- Check if a binary tree is a binary search tree
- Find the height of a binary tree
File Handling
- Read and write to a file
- Count the number of lines, words, and characters in a file
- Append data to a file
- Find the largest and smallest word in a file
- Copy content from one file to another
- Check if a file exists
- Encrypt and decrypt a file
- Replace a specific word in a file
- Merge two files into one
- Count the frequency of a word in a file
Pattern Printing
- Print a pyramid pattern of numbers
- Print a right-angled triangle pattern of stars
- Print an inverted pyramid
- Print Pascal’s triangle
- Print a diamond pattern
- Print Floyd’s triangle
- Print a checkerboard pattern
- Print an alphabet pattern (A, B, C…)
- Print a hollow square or rectangle
- Print a zig-zag pattern
Date and Time Programs
- Swift – Get Current Date
- Swift – Get Current Time
- Swift – Get Difference between Two Dates
- Swift – Find Day of Week for a given Date
- Swift – Add Days to a Given Date
- Swift – Check if a Date is Valid
- Swift – Convert Timestamp to Human-readable Format
- Swift – Find number of Days in a given Month
- Swift – Calculate Age from a Given Birthdate
- Swift – Format Date into Different Styles
- Swift – Find Next Occurrence of a given Weekday
Networking
- Implement a simple client-server program
- Send a file over a network
- Create a chat application
- Fetch data from a URL
- Ping a website
- Check if a port is open
- Implement a basic HTTP server
- Resolve DNS names to IP addresses
- Monitor network usage
- Simulate a simple REST API client