Rohan Vasishth Rohan Vasishth - 1 year ago 216
iOS Question

String Interpolation Segment Error: Swift 3

I recently upgraded my project to swift 3 and have been having some trouble with a string interpolation error.

My code:

let coordString = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".stringByReplacingOccurrencesOfString(".", withString: ",")

The error says:

Static member 'init(stringInterpolationSegment:)' cannot be used on instance of type 'String'

Any help you can offer will be much appreciated!

Answer Source

The method has been renamed in Swift 3:

let coordString = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".replacingOccurrences(of: ".", with: ",")    
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download