Reputation: 1024
I have a custom Swift Class which writes data to the file system using NSKeyedArchiver. One of the functions in this class to do the job is:
func writeDataToArchive (data: AnyObject) {
let dirPath = "\(currentPath)/\(fileName)"
//----
NSKeyedArchiver.archiveRootObject(data, toFile: dirPath)
}
I then call this function like so, by passing it a piece of data to save:
let dataToWrite: [NoteItem] = Hub.allNotes
metaData.writeDataToArchive(dataToWrite)
When I run my program, Xcode is crashing at this line
NSKeyedArchiver.archiveRootObject(data, toFile: dirPath)
with the following Error Message:
2015-10-12 05:25:39.949 MyApp[86437:4755070] *** NSForwarding: warning: object 0x7fe5ba5533c0 of class 'MyApp.NoteItem' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[MyApp.NoteItem replacementObjectForKeyedArchiver:]
Based on the error message it seems to be an issue with something about trying to write my Custom Object to the device. When I use other standard Data Types like Int, String etc...they work fine, so it seems to be an issue with using a Custom Object. How do I fix this?
Upvotes: 1
Views: 1823