使用Objective-C选择器'dealloc'的方法'dealloc()'与使用相同Objective-C选择器的隐式deinitializer冲突

时间:2023-01-15 18:29:53

I was setting up AMScrollingNavbar in Swift. When I tried to convert

我在Swift中设置了AMScrollingNavbar。当我试图转换

- (void)dealloc {
  [self stopFollowingScrollView];
}

to

func dealloc() {
    self.stopFollowingScrollView()
}

an error described in the question occurred. Could you tell me the reason for it and how to deal with it?

问题中描述的错误发生了。你能告诉我它的原因以及如何处理它吗?

1 个解决方案

#1


7  

In swift you need to rename dealloc to deinit, like this:

在swift中你需要将dealloc重命名为deinit,如下所示:

deinit {
 self.stopFollowingScrollView()
}

#1


7  

In swift you need to rename dealloc to deinit, like this:

在swift中你需要将dealloc重命名为deinit,如下所示:

deinit {
 self.stopFollowingScrollView()
}