Hey Julian
you say that you have working swift code to use CBLModel and link the
properties right with @NSManaged?
If so, can you share a class? As an example?
Thank you
On Tuesday, September 16, 2014 3:23:29 AM UTC+2, Julian Paas wrote:
>
> Yes @NSManaged is the same as @dynamic and is working nicely for all my
> other simple, non-array properties.
>
> PlayerStats is a custom class that implements the CBLJSONEncoding protocol
> so that it can be stored as part of a Couchbase document.
>
> class PlayerStats : NSObject, CBLJSONEncoding {
>
> required init(JSON jsonObject: AnyObject!) {
> ...
> }
>
> func encodeAsJSON() -> AnyObject! {
> ....
> }
> }
>
> It took me quite a while to figure out how to return a class in Swift.
> Since I was only about 80% sure that gamePlayerStatsItemClass method is
> correct, I just tested it by creating an objective-C class with a method
> that would call gamePlayerStatsItemClass so I could see what the response
> looks like on the Objective-C side. As far as I can tell, it works. It
> returns a class with a module namespace prefix. i.e. the class is named
> "mymodule.PlayerStats". So the method signature does appear to return an
> objective-C Class.
>
> On Monday, September 15, 2014 6:59:33 PM UTC-4, Jens Alfke wrote:
>>
>>
>> > On Sep 15, 2014, at 1:43 PM, Julian Paas <[email protected]> wrote:
>> >
>> > @NSManaged var gamePlayerStats: [PlayerStats]
>>
>> I haven't gotten into Swift programming yet — is the "@NSManaged"
>> declaration equivalent to "@dynamic" in Objective-C? (It needs to be,
>> otherwise CBLModel won't recognize gamePlayerStats as a database-backed
>> property.)
>>
>> > class func gamePlayerStatsItemClass() -> PlayerStats.Type {
>> > return PlayerStats.self
>> > }
>>
>> That looks OK as far as I know, although I don't know exactly what
>> PlayerStats.Type is. The return type needs to be a Swift equivalent of
>> 'Class'. It's possible that the compiler decided that PlayerStats.Type
>> isn't compatible with anything in Objective-C and decided not to make that
>> method visible from Obj-C, which would explain why it didn't get called…
>>
>> —Jens
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/47b70640-4e46-40c0-a36c-5d4f71dae596%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.