Exercise 1: QuoteFetching Protocol & a Refactored QuoteHeaderView — Possible Solution ============================================================================================ protocol QuoteFetching { func fetchQuote() async throws -> Quote } struct QuoteService: QuoteFetching { func fetchQuote() async throws -> Quote { let url = URL(string: "https://api.example.com/quote/today")! let (data, response) = try await URLSession.shared.data(from: url) guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else { throw URLError(.badServerResponse) } return try JSONDecoder().decode(Quote.self, from: data) } } struct QuoteHeaderView: View { let quoteFetcher: QuoteFetching @State private var quote: Quote? var body: some View { Group { if let quote { VStack(alignment: .leading, spacing: 4) { Text(quote.text).italic() Text("— \(quote.author)").font(.caption) } } else { ProgressView() } } .task { quote = try? await quoteFetcher.fetchQuote() } } } HOW IT WORKS: QuoteFetching declares exactly one real method, fetchQuote(), matching Fundamentals' own free-standing fetchQuote() function's signature. QuoteService wraps that same real URLSession/JSONDecoder logic inside a struct conforming to QuoteFetching, rather than leaving it as a standalone free function - this is what makes it substitutable, following the chapter's own "depend on a protocol, not a concrete implementation" principle. QuoteHeaderView gains a new real let quoteFetcher: QuoteFetching property, supplied through its own initializer rather than calling a hardcoded fetchQuote() function directly inside .task {}. This is initializer injection, exactly as the chapter's own TaskListViewModel example demonstrated, applied here to a View instead of a ViewModel. ANSWER: A QuoteFetching protocol with one fetchQuote() method, a real QuoteService struct implementing it with the original network logic, and a refactored QuoteHeaderView receiving its quoteFetcher via initializer injection rather than calling a hardcoded function directly, correctly applies this chapter's own dependency-injection pattern to Fundamentals' own capstone code. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly extracts the real networking logic behind a protocol and refactors the View to receive it via initializer injection, exactly mirroring the chapter's own TaskListViewModel refactor pattern.