Swift Basics Flashcards - Wyatt's Notes
Swift Basics Flashcards
15 flashcards covering core Swift concepts. Tap a card to reveal the answer.
Intuition
Swift is designed for safety and performance — optionals force you to handle nil at compile time, value types (structs, enums) prevent shared state bugs, and ARC manages memory without a garbage collector. Protocols define capabilities that types adopt, and protocol-oriented programming favours composition over inheritance. Enums in Swift are algebraic data types that can carry associated values, making them far more powerful than C-style enums.
How to Use These Flashcards
First pass: Go through all 15 cards without rating — just flip and read. This familiarises you with the content and identifies weak areas.
Playground practice: After reviewing a card, open a Swift Playground and experiment with the concept. Swift’sREPL and playgrounds make rapid experimentation easy.
iOS/macOS connection: If you’re learning Swift for Apple platforms, relate each concept to its framework use case — optionals for UIKit/SwiftUI properties, protocols for delegate patterns, ARC for memory management.
Common Pitfalls
- Force unwrap (
!): Using!on an optional that is nil crashes the program — preferguard let,if let, or the nil-coalescing operator (??). - Reference cycle with closures: Capturing
selfstrongly in a closure creates a retain cycle — use[weak self]or[unowned self]capture lists. - Value vs reference semantics: Structs are value types (copied on assignment), classes are reference types (shared) — confusion here leads to unexpected mutations.
- String indexing pitfalls: Swift strings are not randomly accessible by integer index — use
String.Indexmethods orenumerated()for iteration. - Actor re-entrancy: Actors protect shared mutable state but are re-entrant — multiple tasks can interleave at
awaitboundaries. Use@Sendableclosures and careful state management to avoid race conditions.
Study Tips
- Use Swift Playgrounds for experimentation: Swift Playgrounds on iPad or Mac let you test code interactively without setting up a full project. This is ideal for learning syntax and APIs.
- Study the Swift Evolution proposals: SE proposals (github.com/apple/swift-evolution) explain why features exist and how they work. Reading SE-0154 (Compact Alternate Roots) and SE-0279 (Add super for single-concat expressions) builds deep understanding.
- Build a SwiftUI project: Applying Swift concepts to a real SwiftUI app reinforces both the language and the framework. Start with a todo app and add features incrementally.
- Practise optionals extensively: Write functions that return optional values and handle them with
if let,guard let,??, and optional chaining. Optionals are Swift’s most distinctive feature. - Study ARC behaviour: Understand strong, weak, and unowned references by creating retain cycles and fixing them. This builds intuition for memory management.
Cross-References
Detailed Content
This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.
Core Concepts
Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.
Worked Examples
Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.
Common Mistakes
- Rushing through foundational material
- Not practising problems after reading
- Failing to connect concepts across topics
Further Reading
Consult the recommended textbooks and additional resources for deeper understanding of this topic.
Detailed Content
This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.
Core Concepts
Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.
Worked Examples
Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.
Common Mistakes
- Rushing through foundational material
- Not practising problems after reading
- Failing to connect concepts across topics
Further Reading
Consult the recommended textbooks and additional resources for deeper understanding of this topic.
Detailed Content
This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.
Core Concepts
Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.
Worked Examples
Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.
Common Mistakes
- Rushing through foundational material
- Not practising problems after reading
- Failing to connect concepts across topics
Further Reading
Consult the recommended textbooks and additional resources for deeper understanding of this topic.
Detailed Content
This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.
Core Concepts
Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.
Worked Examples
Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.
Common Mistakes
- Rushing through foundational material
- Not practising problems after reading
- Failing to connect concepts across topics
Further Reading
Consult the recommended textbooks and additional resources for deeper understanding of this topic.
Detailed Content
This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.
Core Concepts
Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.
Worked Examples
Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.
Common Mistakes
- Rushing through foundational material
- Not practising problems after reading
- Failing to connect concepts across topics
Further Reading
Consult the recommended textbooks and additional resources for deeper understanding of this topic.