【发布时间】:2020-09-24 14:43:53
【问题描述】:
抱歉,我什至不知道要搜索答案的关键字。
我想将全局结构中的所有项目存储到局部变量中。
struct HighScores: Codable {
var highscoreRecord: [HighscoreRecord]
}
struct HighscoreRecord: Codable {
var Rank:Int
var Date:Date
var avDuration:Float
var Score:Int
}
全局变量基于此结构并填充在 UIViewController 中
var jsonResult: HighScores?
现在,在另一个 UIViewController 中,我想提取所有高分的 Score 值并将其存储到局部变量中。我认为它应该看起来像这样,但是,我没有让它工作
@IBDesignable class ScoreTimeGraphView: UIView {
var graphScore = jsonResult!.highscoreRecord.Score
上面的声明抛出“'[HighscoreRecord]'类型的值没有成员'Score'”
任何想法如何做到这一点?
干杯!
【问题讨论】:
标签: arrays swift variables struct