SWIFT
SWIFT
• Swift is a powerful and intuitive programming language developed by
Apple.
• It is used to create apps for iOS, macOS, watchOS, and so on.
• Swift code is concise yet expressive (easier to understand and write).
• Swift is friendly to new programmers, without sacrificing the power
and flexibility that experienced programmers need.
• It’s an industrial-quality programming language that’s as expressive
and enjoyable as a scripting language.
Swift defines away large classes of common programming errors by ad
•Variables are always initialized before use.
•Array indices are checked for out-of-bounds errors.
•Integers are checked for overflow.
•Optionals ensure that nil values are handled explicitly.
•Memory is managed automatically.
•Error handling allows controlled recovery from unexpected failures.
Basic Syntax
var myString = "Hello, World!“
print(myString)
String
for character in "Dog!🐶“
{
print(character)
}
// D
// o
// g
// !
// 🐶
Collections
Collections - Mutable
• If you create an array, a set, or a dictionary, and assign it to a variable,
the collection that’s created will be mutable.
• This means that you can change (or mutate) the collection after it’s
created by adding, removing, or changing items in the collection.
• If you assign an array, a set, or a dictionary to a constant, that
collection is immutable, and its size and contents can’t be changed.