gpt4 book ai didi

cocoa - Swift 协议(protocol) : method does not override any method from its superclass

转载 作者:行者123 更新时间:2023-11-29 05:25:30 25 4
gpt4 key购买 nike

由于 Xcode 6 仍然存在许多 Swift 错误,我不确定是其中之一还是我遗漏了一些东西。我的类采用协议(protocol) NSLayoutManagerDelegate。但似乎不可能覆盖我需要的方法。我按照文档描述的那样做:

override func layoutManager(_ aLayoutManager: NSLayoutManager!,
didCompleteLayoutForTextContainer aTextContainer: NSTextContainer!,
atEnd flag: Bool) {

}

但我在这里收到错误:方法不会覆盖其父类(super class)中的任何方法。我该怎么办?

最佳答案

您正在实现协议(protocol)中的方法,是的,但这不是覆盖。只需删除 override 关键字即可。覆盖是指您的父类(super class)也实现该方法,并且您提供一个版本来替换或修改父类(super class)实现的行为。这不是这里发生的事情。

关于cocoa - Swift 协议(protocol) : method does not override any method from its superclass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58221514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com