Closed sachin-sat closed 7 years ago
I don't understand what you mean. Resource
, ResourceCollection
and LinkedResourceCollection
all implement NSCoding
, so you can encode them for persisting and offline usage.
yeah, that's. Encoding and Decoding won't slow the performance? comparing with sqlite and coredata?
also as it's 'LinkedResourceCollection(in my case it's tomanyrelationship)' used to fetch related 'Objects'. can't i assign them to LinkedResourceCollection of the parent after fetching? i mean self.persons(where person is LinkedResourceCollection) = fetched persons from server which used LinkedResourceCollection?
I don't know what the performance of encoding/decoding is, you'd have to test that if you really want to know. Yes, you can just assign a LinkedResourceCollection
if you want.
Thanks Ward van,
But it also throws error when i try assigning fetched ResourceCollection (from spine.find) to LinkedResourceCollection.
"Cannot assign value of type 'ResourceCollection' to type 'LinkedResourceCollection?'
Am i missing anything?
Thanks in advance.
There is a difference between a LinkedResourceCollection
and a ResourceCollection
, so you cannot assign a ResourceCollection to a variable of type LinkedResourceCollection.
So it's not possible assigning fetched resource to the LinkedResourceCollection of a object? i mean,
class Dogs: Resource { var name: String? var owners: LinkedResourceCollection? override class var resourceType: String { return "dogs" } } class Owner: Resource { var name: String? override class var resourceType: String { return "owner" } }
here dogs.owners always returns LinkedResourceCollection. How i can make it 'Owner' resources after fetching owners using Query(made by LinkedResourceCollection). If i'm wrong, help me please.
Implemented Spine in my project. It works well when in online. I would like to store resources as 'spine resource' without changing anything in my local. I mean if i change anything, relationship between 2 model will be broken right?(in too many relationship). eg : if i want to get Dogs of a Owner from remote API means, it needs resource collection. assume i have 2 dogs fetched from server(stored in local - attributes only) and got one of the dogs and didn't fetch another. and now, again open the App, i have a dog with fetched owners from server and one dog without owner(relationship) in local. Here i can't fetch 2 dog's owner as i don't have resourcecollection of it. Any suggestion to have resourcecollection also in offline?
Thanks in advance.