I build a new Data structure called "CheckItem"(I am doing a Todo project)
and I let CheckItem class inherit the NSObject
and NSCoding
But Xcode alert the compile-time error at line 1:
class CheckItem : NSObject,NSCoding {
the hint is : Use of undeclared type 'NSObject'(and 'NSCoding')
The whole class as follow:
class CheckItem : NSObject,NSCoding {
var text: String
var isDone :Bool
var imageName :String
init(text: String,isDone: Bool,imageName: String){
self.text = text
self.isDone = isDone
self.imageName = imageName
}
init(text: String,isDone: Bool){
self.text = text
self.isDone = isDone
self.imageName = "No Icon"
}
}
Can you point my error? Thank you very much!
Put following statement top in your class:
import Foundation
Even after that you would need to implement following methods to be able to compile. This is because you are implementing NSCoding
protocol so your class must conform to it by implementing these:
public func encodeWithCoder(aCoder: NSCoder)
public init?(coder aDecoder: NSCoder)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With