我有以下变量来自" ScoreHistory.swift":
if ($current_day >= 0 && $current_day <= 4 && $current_time >= 9 && $current_time <= 17 )
我正在尝试将数据显示到&#34; ScoreHistoryViewController.swift&#34;
// ScoreHistory.swift
var datePlayed: NSDate
var totalScore: Int
var totalAnswered: Int
var totalDuration: Int
var gameStatus: String
但他们都错了: 实例成员'____'不能用于'ScoreHistory'类型
这是什么意思?
我的ScoreHistory.swift的完整代码如下所示:
// ScoreHistory.swift
navigationItem.title = ScoreHistory.datePlayed
datePlayedLabel.text = ScoreHistory.datePlayed
totalScoreLabel.text = ScoreHistory.totalScore
totalAnsweredLabel.text = ScoreHistory.totalAnswered
totalDurationLabel.text = ScoreHistory.totalDuration
gameStatusLabel.text = ScoreHistory.gameStatus
答案 0 :(得分:0)
根据您的模型设计,您无法访问类ScoreHistory.datePlayed
您必须创建一个实例。
let history = ScoreHistory(datePlayed: NSDate(), totalScore: 0, totalAnswered: 0, totalDuration: 0, gameStatus: "started")
并调用属性
navigationItem.title = history.datePlayed