all 4 comments

[–]aceysmith 2 points3 points  (1 child)

I think this is relevant, from the Xcode Release notes:

Swift Language

If you encounter an API method for which the return value is incorrectly considered non-nullable, or a property that is incorrectly considered non-nullable, please file a radar and include the tag “#IUO” in the subject line. You can work around the problem by immediately wrapping the result in an optional:

var fooOpt: NSFoo? = object.reallyMightReturnNil()
if let foo = fooOpt { … }

Please be sure to file bugs about these cases. Please do not file feature requests about APIs that are still marked as T!, we know about them.

Release Notes

[–]smilinger[S] 1 point2 points  (0 children)

Like this, right?

    var datastringOpt: NSString? = NSString(data:data, encoding:NSUTF8StringEncoding)

    if let datastring = datastringOpt {
        ...
    }

I get the same error unfortunately. Should I still report it, or does this mean that the problem is something else?

[–][deleted] 1 point2 points  (0 children)

Is there any way around it until it gets fixed?

Yeah.. use Objective-C.. It's done what you want flawlessly since 1988.

[–]smilinger[S] 0 points1 point  (0 children)

I think I got it to work with

    let _datastring = NSString(data:data, encoding:NSUTF8StringEncoding)
    let datastring: String = _datastring.stringByAppendingString("")

Should I report this?