小编May*_*day的帖子

不推荐使用Swift 4:substring(with :)':请使用字符串切片下标

我正在使用html的解码功能.但是我收到了这个警告.我该如何摆脱?

func decode(_ entity : String) -> Character? {

    if entity.hasPrefix("&#x") || entity.hasPrefix("&#X"){
        return decodeNumeric(entity.substring(with: entity.index(entity.startIndex, offsetBy: 3) ..< entity.index(entity.endIndex, offsetBy: -1)), base: 16)
    } else if entity.hasPrefix("&#") {
        return decodeNumeric(entity.substring(with: entity.index(entity.startIndex, offsetBy: 2) ..< entity.index(entity.endIndex, offsetBy: -1)), base: 10)
    } else {
        return characterEntities[entity]
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

swift swift4

7
推荐指数
1
解决办法
4063
查看次数

饼图使用图表库与iOS swift 3

我想在Github上使用piechart danielgindi/Charts库.我的代码是这样的:

import UIKit
import Charts

class ChartViewController: UIViewController {

    @IBOutlet weak var pieChartView: PieChartView!

    override func viewDidLoad() {
        super.viewDidLoad()

    // Do any additional setup after loading the view.

        let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
        let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0]

        setChart(dataPoints: months, values: unitsSold)

    }


    func setChart(dataPoints: [String], values: [Double]) {

        var dataEntries: [ChartDataEntry] = []

        for i in 0..<dataPoints.count {
            let dataEntry1 = PieChartDataEntry(value: Double(i), label: dataPoints[i], data:  dataPoints[i] as AnyObject)
            dataEntries.append(dataEntry1) …
Run Code Online (Sandbox Code Playgroud)

charts ios pie-chart swift swift3

5
推荐指数
1
解决办法
2885
查看次数

标签 统计

swift ×2

charts ×1

ios ×1

pie-chart ×1

swift3 ×1

swift4 ×1