Skip to content

Commit f397d7f

Browse files
Cache data completed
1 parent e88c4cd commit f397d7f

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

Shared/HomeView.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct HomeView: View {
6969
} message: {
7070
Text("Please try again.")
7171
}
72-
.alert("Unavailable Network", isPresented: $unavailableNetworkAlert) {
72+
.alert("Network Unavailable", isPresented: $unavailableNetworkAlert) {
7373
Button("OK", role: .cancel) { }
7474
}
7575
.alert("run out of API credits", isPresented: $runOutOfAPICredits) {
@@ -283,7 +283,6 @@ struct HomeView: View {
283283
try FileManager.default.createDirectory(at: directoryName, withIntermediateDirectories: true)
284284

285285
for abbreviation in abbreviations {
286-
let _ = print(4)
287286
readData(abbreviation)
288287
}
289288
} catch {
@@ -348,7 +347,6 @@ struct HomeView: View {
348347
let cryptocurrency = Cryptocurrency(symbol: meta["symbol"]!, name: meta["currency_base"]!, history: history, abbreviation: abbreviation)
349348
cryptocurrencies.append(cryptocurrency)
350349
cryptocurrencies = sortCryptocurrencyByName(cryptocurrencies)
351-
let _ = print(1)
352350
writeData(cryptocurrency)
353351
} else {
354352
cryptocurrency!.history = history
@@ -365,7 +363,6 @@ struct HomeView: View {
365363

366364
func writeData(_ cryptocurrency: Cryptocurrency) {
367365
do {
368-
let _ = print(2)
369366
let directoryName = getProjectDirectory()
370367

371368
let jsonEncoder = JSONEncoder()
@@ -374,14 +371,12 @@ struct HomeView: View {
374371
let cryptocurrencyDir = directoryName.appendingPathComponent("\(cryptocurrency.abbreviation).txt", isDirectory: true)
375372
try json?.write(to: cryptocurrencyDir, atomically: true, encoding: String.Encoding.utf16)
376373
} catch {
377-
let _ = print(3)
378374
unknownErrorAlert = true
379375
}
380376
}
381377

382378
func readData(_ cryptocurrencyAbbreviation: String) {
383379
do {
384-
let _ = print(5)
385380
let directoryName = getProjectDirectory()
386381
let cryptocurrencyDir = directoryName.appendingPathComponent("\(cryptocurrencyAbbreviation).txt", isDirectory: true)
387382

@@ -392,17 +387,14 @@ struct HomeView: View {
392387

393388
let getCryptocurrency = getCryptocurrency(cryptocurrencyAbbreviation)
394389
if getCryptocurrency == nil {
395-
let _ = print(7)
396390
cryptocurrencies.append(cryptocurrency)
397391
cryptocurrencies = sortCryptocurrencyByName(cryptocurrencies)
398392
} else {
399-
let _ = print(8)
400393
getCryptocurrency!.history = cryptocurrency.history
401394
getCryptocurrency!.price = cryptocurrency.price
402395
doDummyOnCryptocurrencies()
403396
}
404397
} catch {
405-
let _ = print(6)
406398
unknownErrorAlert = true
407399
}
408400
}

0 commit comments

Comments
 (0)