Skip to content

Learn the basics of Swift concepts with visual examples

Notifications You must be signed in to change notification settings

GetStream/enter-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Enter Swift

Learn fundamental Swift concepts with visual examples using SwiftUI. Contact Amos on Twitter: @amos_gyamfi. Each Swift concept explained and illustrated with tangible examples.

What are Type Aliases?

import SwiftUI

/*
 Type aliases define an alternative name for an existing type. You define type aliases with the typealias keyword.
 Type aliases are useful when you want to refer to an existing type by a name that’s contextually more appropriate.
*/

struct TypeAliases: View {
    typealias Emoji = String
    let smiley: Emoji = "😊"
    let winkingFace: Emoji = "πŸ˜‰"
    let moneyFace: Emoji = "πŸ€‘"
    let πŸ’ž: Emoji = "Revolving Hearts"
    
    var body: some View {
        List {
            Text("Smiley face: \(smiley)")
            Text("Winking face: \(winkingFace)")
            Text("Money face: \(moneyFace)")
            Text(πŸ’ž)
        }
    }
}

struct TypeAliases_Previews: PreviewProvider {
    static var previews: some View {
        TypeAliases()
            .preferredColorScheme(.dark)
    }
}

Characters as constant and variable names


How to name constants and variables with characters

Swift alows you to name variables and constants using characters, including Unicode. CharacterConstantVariableNames.swift

Characters as constant and variable names

About

Learn the basics of Swift concepts with visual examples

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published