Type 'Int' does not conform to protocol 'BooleanType'?
In Swift you can't implicitly substitute Int instead of Bool. This was done to prevent confusion and make code more readable.
So instead of this
let x = 10
if x { /* do something */ }
You have to write this:
let x = 10
if x != 0 { /* do something */ }
Also you can't pass an Optional instead of Bool to check if it's nil
, as you would do in Objective-C. Use explicit comparison instead:
if myObject != nil { /* do something */ }
Type 'Int' does not conform to protocol 'BooleanType'
If you want to check, if your currentRow and indexPath are both 5
you can't use an if-statement like that. Change it to:
if indexPath.row == currentRow?.row && currentRow == 5 {
or:
if indexPath.row == 5 && currentRow?.row == 5 {
If you want to check if indexPath
is nil
check if the indexPath is 0
if indexPath.row != 0 && currentRow?.row == 5 {
Type () does not conform to protocol
Try this:
arrayBuildingImage[i] = UIImage(contentsOfFile: path)?
if ( arrayBuildingImage[i] != nil ) {//ERROR HERE
}
else{
break
}
Playground execution failed: EXPR:15:33: error: type 'Int' does not conform to protocol 'BooleanType'
You're missing some of your logic. Change
else if (number % 3 == 0) && (number % 5)
to
else if (number % 3 == 0) && (number % 5 == 0)
Swift 2.0 Type '()' does not conform to protocol
It looks that lockForConfiguration returns Void and throws, so return value does not conform to BooleanType.
I think that the following code should work for you:
if let device = captureDevice {
do {
try device.lockForConfiguration()
device.focusPointOfInterest = focusPoint
device.focusMode = AVCaptureFocusMode.ContinuousAutoFocus
device.exposurePointOfInterest = focusPoint
device.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure
device.unlockForConfiguration()
}
catch {
print("Error")
}
}
Inline if statement mutating inout parameter in a void return closure, weird error (Error: type 'Int1' does not conform to protocol 'BooleanType')
(Adding this thin answer to close the no-longer-relevant question)
The bug described in the question above is no longer present in Swift 2.2 (Xcode 7.3) nor in the Swift 3.0-dev at IBM Sandbox; so the issue seems to have been fixed in with the release of Swift 2.2.
Type HalfOpenIntervalT does not conform to protocol BooleanType
Ranges are meant to be used in a for in
loop:
for i in 0..<cellCount! {
// do stuff
}
Related Topics
Issue with Returning a Directory Enumerator from Nsfilemanager Using Enumeratoraturl in Swift
Swift Display Image UIimageview
Difference Between Sort and Sortinplace in Swift 2
Override UIgesturerecognizer Touchesbegan
Conversion Between Cgfloat and Nsnumber Without Unnecessary Promotion to Double
Bad_Access During Recursive Calls in Swift
How to Retrieve The Name of Participants in Msconversation
How to Cast from Cftyperef to Axuielement in Swift
Swift Protocol Extension Implementing Another Protocol with Shared Associated Type
Swift: Binary Operator '==' Cannot Be Applied to Operands of Type "Protocol"
Type 'Bundle' Has No Member "Module"
How to Create a Cocoapod with .Swift
Member Operator '==' Must Have at Least One Argument of Type
Geocodeaddressstring Not Working for Swift