Sarita Sarita - 3 months ago 17
iOS Question

Type () does not conform to protocol

I don't know the reason but I can't check if an UIImage is

nil
that is the code

var arrayBuildingImage: [UIImage] = []

for(var i = 0; i <= 100; i++){

var path:String = self.getDocumentsDirectory().stringByAppendingPathComponent("building/\(i).png")

if ( arrayBuildingImage[i] = UIImage(contentsOfFile: path)? ) {//ERROR HERE

}
else{
break
}

}


Error:

Type () does not conform to protocol 'BooleanType'

I'm using Swift 1.1

Answer

Try this:

        arrayBuildingImage[i] = UIImage(contentsOfFile: path)?
        if ( arrayBuildingImage[i] != nil ) {//ERROR HERE

        }
        else{
            break
        }
Comments