0
私はhttps://blockchain.info/tickerに分割したいので、各行は配列内の独自の文字列になります。このjsonを配列内の別々の文字列に分割する方法
私が選択した通貨の価格を表示するAppを作成しています。したがって、誰かがAUDを望むなら、それは配列内の2文字列を取得し、最後のタグにある価格を表示します。私は現在持っているものの単なるコピー&ペースト
私は現在、ちょうどそれがJSONをダウンロードする必要があり..
func reloadJson(){
if globalVariables.currencySelected == "" {
globalVariables.currencySelected = globalVariables.currencySelected + "AUD"
}
print(globalVariables.currencySelected)
if let blockchainTickerURL = URL(string: "https://blockchain.info/ticker") {
let request = NSMutableURLRequest(url: blockchainTickerURL)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
var message = ""
if error != nil {
print("error")
} else {
if let unwrappedData = data {
let dataString = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue)
ザッツは、その正確右のフォーマットされていません。
ありがとうございます。
文字列を分割してJSONを解析している場合、間違っています。 Swift用のJSONDecoderを参照してください –
ありがとう、私はそれを変更しました。私は何をしようとしているのか考えていますか? –
Xcode 9.2 on High Sierra –