I am using the following code to try to test an FTP connection:
func OpenAndTestFTPConn(user:NSString, pass:NSString) -> Bool {
var ftpstring = "ftp://\(user):\(pass)@\(txtTarget.stringValue)"
var ftpNSURL = NSURL(string: ftpstring)
var FTPStream = CFReadStreamCreateWithFTPURL(nil, ftpNSURL)
var status:Bool
var cfstatus:Boolean = CFReadStreamOpen(FTPStream) as Boolean
if cfstatus == 0 {
status = false
}
else {
status = true
}
println(status)
return status
}
When I try building this, the line var cfstatus:Boolean = CFReadStreamOpen(FTPStream) as Boolean
returns the error Cannot convert the expression's type 'Boolean' to type 'CFReadStream!'
. If I remove the type declarations on both sides of the expression, the error returned is Cannot convert the expression's type 'Boolean' to type '$T3'
.
Where am I going wrong?
Note: the cstatus
definition and statements are based on this post.