SkygearIO / skygear-SDK-iOS

Skygear SDK for iOS
https://skygear.io
Other
10 stars 28 forks source link

Deserializing record to custom subclass #65

Open cheungpat opened 7 years ago

cheungpat commented 7 years ago

From the chat SDK, there is some code to copy a SKYRecord and create a custom subclass (such as SKYMessage. I suggest that we make `SKYRecordDeserializer deserializer] to return a singleton object and SDK user can register subclass to be used for deserialization when the deserializer encounter certain types:

id der = [SKYRecordDeserializer deserializer];
[der registerRecordClass:[SKYMessage class] forType:@"message"];

id record = [der recordWithDictionary:recordDict];
[record isKindOfClass:[SKYMessage class]]; // true