Actually I got the address field string from the api like "District-1 1656-Union-Street Eureka 707-445-6600", so I need to convert into Array.
Expected Result :
["District-1", "1656-Union-Street", "Eureka", "707-445-6600"]
As I can get the Array from the components
method using space as a separator.
//Code
var getAddress = addInfo.components(separatedBy: " ")
//Result
["District-1", "", "", "1656-Union-Street", "", "", "Eureka", "", "707-445-6600"]
But the problem is that it will return the empty object also.
You can apply the
split
method for accomplished the task.For i.e.
For more information please review the link