Animation
Implicit and explicit motion, curves, state and game feel.
Explore the ideas behind modern apps through live simulations, editable code, predictions, quick checks, and a computational app studio.
Implicit and explicit motion, curves, state and game feel.
Camera, microphone, location, privacy and purpose strings.
Requests, JSON, Codable, URLSession and live data.
throw, try, do-catch and thoughtful debugging.
Progress is dated and saved only in this browser on this device.
Study the idea and instructions.
2 · TRYChange every highlighted control.
3 · OBSERVEWatch the code and preview update.
4 · EXPLAINAnswer checks in your own words.
Animation is a smooth transition between values. Change the controls, then connect what you see to the SwiftUI code.
Animation smoothly changes a view property—such as scale, position, rotation or opacity—from one value to another. The changing value is usually stored in @State.
Attach .animation(..., value:) to a view. SwiftUI watches the chosen value and animates whenever it changes.
continuous or automatic effects such as pulsing stars, spinning coins and loading indicators.
Wrap a state change inside withAnimation { }. Only the changes in that action are animated.
button taps and gestures such as launching a rocket, moving a target or flipping a card.
ContentView.swift, press Run, and compare the real SwiftUI animation with this simulation.Implicit animation watches isPulsing
Because this is implicit, the modifier watches a value and animates automatically whenever that value changes.
withAnimation.Software must ask before it reaches beyond its sandbox. Build the two-part permission handshake.
To use hardware in Swift Playgrounds, an app completes a two-step handshake:
Privacy rule: Request access only when the feature is needed. A user’s denial must be respected.
| Capability | Framework | Purpose String Key | Example Purpose String |
|---|---|---|---|
| Camera | AVFoundation | NSCameraUsageDescription | “We need the camera so you can take a profile picture.” |
| Microphone | AVFoundation | NSMicrophoneUsageDescription | “We need the microphone to record your voice notes.” |
| Location | CoreLocation | NSLocationWhenInUseUsageDescription | “We need your location to show nearby restaurants.” |
| Photo Library | PhotosUI | NSPhotoLibraryUsageDescription | “We need access to save your edited artwork.” |
Add the capability and a clear purpose string in App Settings.
Use the correct framework and authorization code.
Show a helpful UI for allowed, denied or undetermined states.
Waiting to ask…
Follow the journey from a user request to live data on the screen—without freezing the interface.
An API (Application Programming Interface) is a software messenger that allows two different computer systems to communicate. A REST API follows web-based rules: your app sends a request to an endpoint, and a server returns a response, often as JSON. Swift uses Codable and JSONDecoder to translate that JSON into Swift data.
Before coding: In App Settings, enable Outgoing Network Connections so the app can act as a client.
Your SwiftUI app is the customer. It asks for information through an endpoint.
Send a request and observe each stage.
Tap one of the purple JSON key buttons below. Its matching Swift property will light up on the right.
Choose a key to see how JSONDecoder matches the spelling and data type.
Good code anticipates failure, explains the problem and gives the user a safe next step.
A syntax or spelling mistake detected by Swift before the app can run—for example, a missing brace or typing Buton.
An unexpected problem during use—for example, lost Wi-Fi, a missing file or invalid input. Without handling, it may crash the app.
Swift’s safety net is do-catch: a function marked throws can throw an error; the caller uses try; and catch provides a safe response.
The safety net is waiting.
do {
try submitOrder()
message = "Order sent!"
} catch OrderError.kitchenClosed {
message = "Kitchen is closed."
} catch {
message = "Something went wrong."
}import SwiftUI
enum OrderError: Error {
case outOfStock
case kitchenClosed
}
struct ContentView: View {
@State private var message = "Ready to Order"
@State private var itemsInStock = 1
@State private var isKitchenOpen = true
func submitOrder() throws {
if !isKitchenOpen {
throw OrderError.kitchenClosed
}
if itemsInStock == 0 {
throw OrderError.outOfStock
}
itemsInStock -= 1
}
var body: some View {
VStack(spacing: 30) {
Text("Soto Order System")
.font(.largeTitle)
.bold()
Text(message)
.multilineTextAlignment(.center)
Toggle("Kitchen is open", isOn: $isKitchenOpen)
Button("Submit Order to Kitchen") {
do {
try submitOrder()
message = "Success! Order sent to the kitchen."
} catch OrderError.kitchenClosed {
message = "The kitchen is currently closed."
} catch OrderError.outOfStock {
message = "This item is sold out."
} catch {
message = "An unknown error occurred."
}
}
.buttonStyle(.borderedProminent)
}
.padding()
}
}Combine one input, one computation and one useful output. This is a small taste of planning a complete app.
Pseudocode is a plain-language plan for an algorithm. It is not real Swift code, so it does not need exact punctuation. It should show the order of the input, decision/process and output.
START
GET the weather temperature
IF temperature is above the safety limit
SHOW “Choose an indoor activity”
ELSE
SHOW “Conditions are suitable”
END IF
ENDUse clear action words such as GET, SET, CALCULATE, IF, ELSE, SHOW and REPEAT.
Help a traveller decide whether conditions are safe.
Imagine that the app has already been created. Test it with two sample situations. Record the input, the expected output and what the app should do if something goes wrong.
Complete a mix of prediction, matching, debugging and design decisions.
Twenty varied missions are waiting.
A score of 16/20 or higher is marked as Mastered.
Your report records what you actually tried—not only what you marked complete.
Complete the worlds and interact with their controls to build evidence.
Answers completed before this reporting update may need to be selected once more. Existing scores and completion remain saved.
Save or print your summary as PDF.
Save it first inside your ComputerScience folder. On iPad: Share/Print → pinch out the preview → Share → Save to Files.
Rename the file:Name_sec2FaithCodeQuest.pdf
Replace Name with your complete name.
Submit using your school email.
Open your class’s CodeQuest folder. Create a folder using your complete name, set General access to Restricted, share it only with your teacher’s school email, and make your teacher an Editor. Upload your PDF inside your folder.