Complete the code to import the framework that allows access to device features.
import [1]
The UIKit framework provides the necessary APIs to access many device capabilities like the screen, touch, and sensors.
Complete the code to request permission to use the device camera.
AVCaptureDevice.requestAccess(for: .video) { granted in if [1] { print("Camera access granted") } else { print("Camera access denied") } }
The closure parameter 'granted' is a Boolean indicating if the user allowed camera access.
Fix the error in the code to get the current device orientation.
let orientation = UIDevice.current.[1]The correct property to get the device's orientation is 'orientation' on UIDevice.current.
Fill both blanks to create a dictionary that maps sensor names to their availability status.
let sensors = ["Accelerometer": [1], "Gyroscope": [2]]
CMMotionManager provides properties to check if accelerometer and gyroscope sensors are available on the device.
Fill all three blanks to create a dictionary comprehension that filters sensors available on the device.
let availableSensors = [
[1]: [2] for [3] in ["Accelerometer", "Gyroscope", "Magnetometer"]
if CMMotionManager().is[1]Available
]This code creates a dictionary with sensor names as keys and 'true' as values only if the sensor is available.