Oyvindkg / swiftydb

💀Neither supported nor maintained for years. A type-safe, protocol-based, pure Swift database offering effortless persistence of any object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arrays?

steelzeh opened this issue · comments

Add support for arrays?

class Person: NSObject, Storable {
    var person:[Children]
}

class Children: NSObject, Storable {

    var name:String!
    var age:NSNumber!
}

I'm getting this
[testapp.Children encodeWithCoder:]: unrecognized selector sent to instance

Hello steelzeh,

Only objects conforming to NSCoding can be stored in collections. NSCoding is used to encode and decode objects.

NSHipster have written a Swift tutorial for the NSCoding protocol. I recommend you to check it out.

Thanks for pointing it out. I will update the documentation.

Ohh shit didn't know that. I'll try adding NSCoding.
But will it just store the objects as NSData?

Yes, all collections will be converted to NSData. The plan is to store Storable objects in their respective tables, but this isn't implemented yet.

I have just delivered my final exam for the semester, so I will have some time to kill in the coming weeks. I hope to work on SwiftyDB as much as possible.