Question: Convert below string to NSArray

Question

Convert below string to NSArray

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

Actually i am getting this data from remote file

http://appsnurture.com/csv/sample.csv

"\"030506941\"\n\"032752389\"\n\"033415694\"\n\"035010096\"\‌​n\"035010106\"\n\"03‌​5010108\"\n\"0350101‌​18\"\n

if let url = NSURL(string: "http://appsnurture.com/csv/sample.csv") {
            let data = NSData(contentsOfURL: url)
            let resstr = NSString(data: data!, encoding: NSUTF8StringEncoding)!
            print(resstr)
        }

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