I'm using Google's 'reverseGeocodeCoordinate
' to get address based on latitude and longitude.
I'm getting the following error in the implementation
Ambiguous reference to member 'joinWithSeparator'
Below is my implementation:
let aGMSGeocoder: GMSGeocoder = GMSGeocoder()
aGMSGeocoder.reverseGeocodeCoordinate(CLLocationCoordinate2DMake(17.45134626, 78.39304448)) {
(let gmsReverseGeocodeResponse: GMSReverseGeocodeResponse!, let error: NSError!) -> Void in
let gmsAddress: GMSAddress = gmsReverseGeocodeResponse.firstResult()
print("lines=\(gmsAddress.lines)")
let addressString = gmsAddress.lines.joinWithSeparator("")
print("addressString=\(addressString)")
}
I'm trying to create a addressString
with the elements in array 'gmsAddress.lines
', but end up with an error message.
Implemented some sample snippet to test 'joinWithSeparator
'
let sampleArray = ["1", "2", "3", "4", "5"]
let joinedString = sampleArray.joinWithSeparator("")
print("joinedString=\(joinedString)")
It succeeded.
What I observe is, 'sampleArray
' is an array of elements of type String
, but 'gmsAddress.lines
' is an array of elements of type 'AnyObject
', Found in 'GMSAddress
' library:
/** An array of NSString containing formatted lines of the address. May be nil. */
public var lines: [AnyObject]! { get }
So, What are the possible ways to achieve the following line without looping the array:
let addressString = gmsAddress.lines.joinWithSeparator("")