> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Swift Convenience Initializer

A convenience initializer is a secondary, supporting initializer for a class that provides an alternative initialization path. It must strictly delegate initialization responsibility to a designated initializer within the exact same class before it is permitted to access `self` or modify any properties.

In Swift, the `convenience` modifier is exclusive to reference types (classes). Value types (structs and enums) can perform cross-delegation without this keyword.

## Syntax

A convenience initializer is declared by placing the `convenience` modifier immediately before the `init` keyword.

```swift theme={"dark"}
convenience init(parameters) {
    self.init(arguments)
    // Property modification occurs here
}
```

## Delegation Rules

Swift enforces strict rules for class initialization to guarantee memory safety, commonly referred to as the **Rule of Three**:

1. **Delegation Across:** A convenience initializer must call another initializer from the *same* class using `self.init`. It cannot call a `super.init` directly.
2. **Ultimate Resolution:** A convenience initializer must ultimately resolve to a designated initializer. It can call another convenience initializer, but the chain of calls must end at a designated initializer.
3. **Designated Delegation Up:** Only designated initializers are permitted to delegate up to a superclass initializer.

## Two-Phase Initialization Constraints

Convenience initializers are bound by Swift's two-phase initialization process.

* **Phase 1:** The convenience initializer must delegate across (`self.init`) before it can assign a value to *any* property, including properties defined in its own class.
* **Phase 2:** Once the designated initializer completes the memory allocation and base initialization, control returns to the convenience initializer, which is then permitted to mutate properties or call instance methods.

## Structural Example

The following code demonstrates the mechanical routing of convenience initializers without relying on a specific implementation use-case:

```swift theme={"dark"}
class Entity {
    var identifier: Int
    var status: String

    // Designated Initializer
    init(identifier: Int, status: String) {
        self.identifier = identifier
        self.status = status
    }

    // Convenience Initializer delegating to Designated Initializer
    convenience init(identifier: Int) {
        // Phase 1: Must delegate across before property mutation
        self.init(identifier: identifier, status: "Pending")
        
        // Phase 2: 'self' is now fully initialized and mutable
        self.status = "Active" 
    }

    // Convenience Initializer delegating to another Convenience Initializer
    convenience init() {
        // Resolves to the designated initializer via the chain
        self.init(identifier: 0)
    }
}
```

## Inheritance Behavior

Convenience initializers are not directly overridden by subclasses. However, they are subject to Swift's automatic initializer inheritance rules:

* If a subclass does not define any designated initializers, it automatically inherits all of its superclass designated and convenience initializers.
* If a subclass provides an implementation for *all* of its superclass's designated initializers (either by inheriting them or overriding them), it automatically inherits all of the superclass's convenience initializers.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Swift Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
