0
0
iOS Swiftmobile~10 mins

Why advanced patterns create premium apps in iOS Swift - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a SwiftUI view struct.

iOS Swift
struct ContentView: [1] {
  var body: some View {
    Text("Hello, world!")
  }
}
Drag options to blanks, or click blank then click option'
AView
BUIViewController
CAppDelegate
DSceneDelegate
Attempts:
3 left
💡 Hint
Common Mistakes
Using UIKit classes like UIViewController instead of SwiftUI View.
2fill in blank
medium

Complete the code to create a state variable in SwiftUI.

iOS Swift
@[1] private var count = 0
Drag options to blanks, or click blank then click option'
AEnvironmentObject
BState
CObservedObject
DBinding
Attempts:
3 left
💡 Hint
Common Mistakes
Using @ObservedObject or @Binding when a simple state is needed.
3fill in blank
hard

Fix the error in the code by completing the missing protocol conformance.

iOS Swift
class DataModel: [1] {
  @Published var name = ""
}
Drag options to blanks, or click blank then click option'
ACodable
BIdentifiable
CObservableObject
DEquatable
Attempts:
3 left
💡 Hint
Common Mistakes
Using Identifiable or Codable which do not support @Published.
4fill in blank
hard

Fill both blanks to create a computed property that filters an array.

iOS Swift
var filteredItems: [String] {
  items.filter { $0.[1]([2]) }
}
Drag options to blanks, or click blank then click option'
Acontains
B"a"
C"b"
Dstarts(with)
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'starts(with)' with wrong substring or missing quotes.
5fill in blank
hard

Fill all three blanks to filter a dictionary for positive values.

iOS Swift
let positiveScores = scores.filter { [1], [2] in [2] [3] 0 }
Drag options to blanks, or click blank then click option'
Aplayer
Bscore
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for filtering positive scores.