iOS Swift - Swift Language EssentialsWhich of the following is the correct way to declare a Boolean variable named isActive with value true in Swift?Avar isActive: Bool = trueBlet isActive = 1Cvar isActive: Int = 1Dlet isActive = "true"Check Answer
Step-by-Step SolutionSolution:Step 1: Understand Boolean declarationBoolean variables use Bool type and true/false values without quotes.Step 2: Check each optionvar isActive: Bool = true declares a Bool variable with true correctly.Final Answer:var isActive: Bool = true -> Option AQuick Check:Boolean declaration = var isActive: Bool = true [OK]Quick Trick: Bool values are true or false without quotes [OK]Common Mistakes:Using quotes around true/falseUsing Int instead of BoolUsing let with wrong type
Master "Swift Language Essentials" in iOS Swift9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepUITryChallengeBuildRecallPublish
More iOS Swift Quizzes State Management in SwiftUI - @Published properties - Quiz 1easy Swift Language Essentials - Error handling (try, catch, throw) - Quiz 9hard SwiftUI Basics - Spacer and padding - Quiz 15hard SwiftUI Basics - VStack, HStack, ZStack - Quiz 2easy SwiftUI Layout - ScrollView - Quiz 9hard SwiftUI Layout - GeometryReader for adaptive layouts - Quiz 15hard SwiftUI Layout - GeometryReader for adaptive layouts - Quiz 3easy User Input and Forms - Stepper - Quiz 8hard User Input and Forms - Form container - Quiz 13medium User Input and Forms - TextField - Quiz 10hard