I am following Apple\'s Docs to create a PDF file using Xcode6-Beta6 in Swift
var currentText:CFAttributedStringRef = CFAttributedStringCreate(nil, textView.
First you have to give it an explicit optional type (using the ?
):
var currentText: CFAttributedStringRef? = ...
Then you can compare it to nil:
if currentText != nil {
// good to go
}
Your code compiles at the moment, because Apple hasn't yet "swiftified" CoreFoundation to return properly annotated types.
Be prepared that in the final release your code will not even compile, forcing you to use the optional type.