【发布时间】:2020-07-02 16:25:06
【问题描述】:
我收到此错误“Missing return in a function expected to return 'NSAttributedString?'”
有人可以帮忙吗?我正在为这件事打败我的小脑袋——容易犯白痴错误。我输入了“dummyString”行以确保有回报,但没有运气。
TIA
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let dummyString = "Dummy String"
if component == 1 {
return NSAttributedString(string: denomArray[row], attributes: [NSAttributedString.Key.foregroundColor: UIColor.yellow])
}else if component == 0 {
if issuerArray [row] == "US" {
return NSAttributedString(string: self.issuerArray[row], attributes: [NSAttributedString.Key.foregroundColor: BaseViewController.Flag.us.themeColor])
}
if issuerArray [row] == "Canada" {
return NSAttributedString(string: self.issuerArray[row], attributes: [NSAttributedString.Key.foregroundColor: BaseViewController.Flag.canada.themeColor])
}
}else{
return NSAttributedString(string: dummyString, attributes: [NSAttributedString.Key.foregroundColor: UIColor.red])
}
}
【问题讨论】:
标签: ios swift if-statement return