Not working in Swift inheriting from NSObject
I have a very simple model, it's a few booleans, Strings, and so on.
import AutoCoding
public class Bitlink : NSObject {
var longURLString = ""
var shortURLString = ""
var archived = false
var title: String? = ""
... and so on
}
I'm using YapDatabase, which is leveraging NSCoder for persistence. When I save and read from the database, what I saved is correct going in and reading back out. Then when I restart the app, and query, it comes back with the default values.
I tried manually using initWithCoder: and encodeWithCoder:, and that resolved the issues, so I'm fairly certain this has something to do with AutoCoding.
Any thoughts?
I'm going to need a bit more information. Can you provide a sample app?
Here you go. http://www.filedropper.com/autocodingtest
In ViewController.swift, I uncommented out the code in viewDidLoad to save a Dog.
Then I close the app, and comment it out, so no dogs are saved. Then I run the app, enumerating through all the saved Dogs, and it will show 1 Dog, with the default properties that Dog's are initialized with.
I then delete the app, so I don't get an encoding conflict, and in Dog.swift I switch to manual encoding.
I repeat the process, save a Dog by uncommenting the code, close the app, comment out the code that saves dogs, enumerate through the dogs, and this time it pulls up the correct Dog object, not one initialized with the default properties.
Please let me know if that's unclear, and if I can help in any way.
Thanks!