无法分配给 属性:"description" 属性 是不可变的错误 ( leftSwipe.description = .Left)

Cannot assign to property: "description" property is immutable error with ( leftSwipe.description = .Left)

我正在关注有关滑动手势的 YouTube 视频教程。我正在编写的代码与教程中显示的完全一样,但我收到错误消息(无法分配给 属性:"description" 属性 是不可变错误) 在线 (leftSwipe.description = .Left)

override func viewDidLoad() {
        super.viewDidLoad()

var leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes"))

leftSwipe.description = .Left
 }

教程作者以完全相同的方式编写它,但没有收到我遇到的错误。 我将不胜感激。 Link 我关注的 YouTube 视频教程是:https://www.youtube.com/watch?v=9r1UFNeVuFA

不是description,你用错了属性名字,应该是direction.

不是description

 leftSwipe.description = .Left

direction

leftSwipe.direction = UISwipeGestureRecognizerDirection.Left 

// or use 

 leftSwipe.direction = .Left 
override func viewDidLoad() 
{      
    super.viewDidLoad()

    var leftSwipe = UISwipeGestureRecognizer(target: self, action:     
    Selector("handleSwipes"))

    leftSwipe.direction = .Left
 }

使用

 leftSwipe.direction = .Left