Bird
0
0

What is the main purpose of a protocol in Swift?

easy📝 Conceptual Q11 of 15
iOS Swift - Swift Language Essentials
What is the main purpose of a protocol in Swift?
ATo create a new class with default behavior
BTo define a blueprint of methods and properties that a type must implement
CTo store data persistently on the device
DTo handle user interface layout automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand what a protocol defines

    A protocol specifies methods and properties that a type must implement, acting as a blueprint.
  2. Step 2: Differentiate from other concepts

    Protocols do not create classes or store data; they only define requirements.
  3. Final Answer:

    To define a blueprint of methods and properties that a type must implement -> Option B
  4. Quick Check:

    Protocol purpose = blueprint [OK]
Quick Trick: Protocols define required methods and properties [OK]
Common Mistakes:
  • Confusing protocols with classes
  • Thinking protocols store data
  • Assuming protocols handle UI layout

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes