不能在属性初始值设定项中使用实例成员;属性初始化程序在'self'可用之前运行

时间:2017-10-19 19:51:50

标签: swift

我在属性初始化程序中得到一个“无法使用实例成员'onwardTimeCount';属性初始化程序在'self'可用之前运行”下面是以下代码

class TripStatus {
    var startDate: Int = Utility.getTimestampAfter(daysInterval: 1)
    var tripType = SelectedTripType.roundTrip
    var subscriptionType = SelectedSubscriptionType.monthly
    var onwardTimeCount: TimeInterval = TimeInterval(ApplicationSettingsKey.startTimeFirstShift.key ?? "00:00 AM") ?? 3600
    var returnTimeCount: TimeInterval = TimeInterval(ApplicationSettingsKey.returnTimeFirstShift.key ?? "00:00 AM") ?? 3600
    var oneWayOnwardJourneyTime: String = Utility.timeString(time: onwardTimeCount ?? 100 * 60)
}

但我得到的错误是这样的:

enter image description here

enter image description here

0 个答案:

没有答案