Am I taking crazy pills? Directly out of the documentation:
“Swift automatically bridges between the String type and the NSString class. This means that
You already have the answer in your question. You're missing the cast. When writing Swift code, a statement such as this one
var str = "Hello World"
creates a Swift String
, not an NSString
. To make it work as an NSString
, you should cast it to an NSString
using the as
operator before using it.
This is different than calling a method written in Objective-C and supplying a String
instead of an NSString
as a parameter.