【发布时间】:2018-12-21 17:55:00
【问题描述】:
我只是在更新后更新 xcode(10.0) 以及 swift 语言版本(4.2),但在更新 swift 语言的过程中给了我一些错误。我真的很困惑如何解决这个问题:
错误:
类型 'NSCoder' 没有成员 'plain'
var _followingChatControl: FollowingChat!
var followingChatControl: FollowingChat {
get {
if _followingChatControl == nil {
_followingChatControl = FollowingChat.init(coder: .plain)
}
return _followingChatControl
}
set {
_followingChatControl = newValue
}
}
错误截图:
FollowingChat 类代码:
import UIKit
class FollowingChat: AbstractTableListControl{
var listDataFollowing: [Following]?
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.separatorStyle = .none
self.tableView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
self.tableView.delegate = self
}
override var cellClass: AbstractTableCell.Type {
return ScreenChatCell.self
}
override var isNibUsed: Bool {
return true
}
override func refresh() {
super.refresh()
}
FollowingChat 类屏幕截图:
【问题讨论】:
-
如果不知道
FollowingChat是什么以及它有哪些初始化程序,就不可能回答您的问题。 -
漂亮的 objective-c-ishly 气味代码。在 Swift 中,
lazy var followingChatControl = FollowingChat(coder: .plain)行完全一样。 -
@MartinR 请检查
-
我仍然看不到您的代码中的
init(coder:)初始化程序... -
在更新 xcode 以及 swift 版本后显示错误类型 'NSCoder' 没有成员 'plain'