在将颜色UIColor
添加到现有类之前,我的代码很好。添加颜色后:UIColor
追加我的代码部分是错误(缺少','参数)。
我只粘贴了部分代码。请参阅底线以了解错误。
import Foundation
import UIKit
class DestinationType {
var name: String // name of destination type
var destinations : [Destination] // all destinations in the type
init (name:String, includeDestination:[Destination]) {
self.name = name
self.destinations = includeDestination
}
class func destinationTypes() -> [DestinationType] {
return [self.summer(), self.winter()]
}
private class func summer() -> DestinationType {
var destinations = [Destination]()
destinations.append(Destination(name: "Antalya", description: "Very", imageName: "antalya.png", color: UIColor.greenColor)
//预期','分隔符 }
如果需要,请在下面找到我的课程文件。
import Foundation
import UIKit
class Destination {
var name : String
var description : String
var image : UIImage
var color : UIColor
init (name:String, description:String, imageName:String, color:UIColor) {
self.name = name
self.description = description
if let img = UIImage(named: imageName) {
image = img
}
else {
image = UIImage(named: "default")!
}
self.color = color
}
}
答案 0 :(得分:0)
destinations.append(Destination(name: "Antalya", description: "Very", imageName: "antalya.png", color: UIColor.greenColor)
该行有两个(
,只有一个)
答案 1 :(得分:0)
greenColor
错过了括号。它必须是greenColor()
。
Swift的错误消息比给出错误的任何好的提示更具误导性: - (