Question: Convert below string to NSArray


Convert below string to NSArray

Answers 1
Added at 2017-01-04 13:01

Actually i am getting this data from remote file


if let url = NSURL(string: "") {
            let data = NSData(contentsOfURL: url)
            let resstr = NSString(data: data!, encoding: NSUTF8StringEncoding)!

How i can parse above string to array without quote mark. I am open for another option for parsing CSV from URL.

Answers to

Convert below string to NSArray

nr: #1 dodano: 2017-01-04 13:01

Please Try something like

var str = "your string"
var newString =  str.stringByReplacingOccurrencesOfString("\"", withString: "")
var newString2 =  newString.stringByReplacingOccurrencesOfString("\n", withString: " ")
var arrayWithoutQOutes = newString2.characters.split{$0 == " "}.map(String.init)
Source Show
◀ Wstecz