Goal: Experience AI-powered code completion while writing Swift code.
Scenario: Add a description field to the landmark row display.
- Open LandmarkRow.swift
Path:
Landmarks/Views/Landmarks/LandmarkRow.swift - Locate the
HStackcontaining the landmark name (around line 14) - Below the landmark name
Textview, add this comment:
// Display the landmark description in one line; show full description on hover- Press Enter and wait for Copilot to suggest code
- You should see a suggestion like:
Text(landmark.description)
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(1)- Press Tab to accept the suggestion
- Add a comment for a date formatter
- Write a comment to create a computed property for landmark categories
- Start typing a function name and let Copilot complete the implementation
You've learned how to:
- Trigger inline code suggestions with comments
- Accept suggestions with Tab
- Guide Copilot with descriptive comments