Skip to content

Commit c939df0

Browse files
committed
Update AAChartView+API.swift
1 parent a64a8b4 commit c939df0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

AAInfographics/AAChartCreator/AAChartView+API.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
*/
3232

33+
import Foundation
34+
3335
// MARK: - Configure Chart View Content With AAChartModel
3436
@available(iOS 10.0, macCatalyst 13.1, macOS 10.13, *)
3537
extension AAChartView {
@@ -69,12 +71,16 @@ extension AAChartView {
6971
public func aa_drawChartWithChartOptions(_ aaOptions: AAOptions) {
7072
if optionsJson == nil {
7173
configureOptionsJsonStringWithAAOptions(aaOptions)
72-
let path = BundlePathLoader()
74+
guard let path = BundlePathLoader()
7375
.path(forResource: "AAChartView",
7476
ofType: "html",
75-
inDirectory: "AAJSFiles.bundle")
76-
let urlStr = URL(fileURLWithPath: path!)
77-
let urlRequest = URLRequest(url: urlStr)
77+
inDirectory: "AAJSFiles.bundle") else {
78+
// Consider more robust error handling or logging framework for production code
79+
print("Error: AAChartView.html not found in AAJSFiles.bundle. Chart cannot be loaded.")
80+
return
81+
}
82+
let fileURL = URL(fileURLWithPath: path) // 'path' is a non-optional String here
83+
let urlRequest = URLRequest(url: fileURL)
7884
load(urlRequest)
7985
} else {
8086
aa_refreshChartWholeContentWithChartOptions(aaOptions)

0 commit comments

Comments
 (0)