{"action":"created","issue":{"url":"https://api.github.com/repos/Mantle/Mantle/issues/695","repository_url":"https://api.github.com/repos/Mantle/Mantle","labels_url":"https://api.github.com/repos/Mantle/Mantle/issues/695/labels{/name}","comments_url":"https://api.github.com/repos/Mantle/Mantle/issues/695/comments","events_url":"https://api.github.com/repos/Mantle/Mantle/issues/695/events","html_url":"https://github.com/Mantle/Mantle/issues/695","id":150163367,"number":695,"title":"NSKeyedArchiver MTLModel with nested NSArray of MTLModel","user":{"login":"crsantos","id":25558,"avatar_url":"https://avatars.githubusercontent.com/u/25558?v=3","gravatar_id":"","url":"https://api.github.com/users/crsantos","html_url":"https://github.com/crsantos","followers_url":"https://api.github.com/users/crsantos/followers","following_url":"https://api.github.com/users/crsantos/following{/other_user}","gists_url":"https://api.github.com/users/crsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/crsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crsantos/subscriptions","organizations_url":"https://api.github.com/users/crsantos/orgs","repos_url":"https://api.github.com/users/crsantos/repos","events_url":"https://api.github.com/users/crsantos/events{/privacy}","received_events_url":"https://api.github.com/users/crsantos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-21T19:03:32Z","updated_at":"2016-04-22T09:29:02Z","closed_at":null,"body":"This is more a doubt than an issue, I guess.\r\nI would like to know how to serialise/desirialize from NSKeyedArchiver a MTLModel with another nested MTLModel.\r\n\r\nImagine that I have a `User` model that contains a property that is an array of `Dog` like the following:\r\n\r\n```obj-c\r\n@interface Dog : MTLModel <MTLJSONSerializing>\r\n@property (nonatomic, copy) NSString *dogName;\r\n@end\r\n\r\n@interface User : MTLModel <MTLJSONSerializing>\r\n@property (nonatomic, copy) NSString *userId;\r\n@property (nonatomic, strong) NSArray<Dog *> *dogs;\r\n@end\r\n```\r\n\r\nRight now I'm serialising a `User` like this `[NSKeyedArchiver archiveRootObject:movie toFile:filename];` but when I deserialise it, the array of dogs is empty...\r\n\r\nAm I missing something?\r\nShould I store only the JSON model instead of trying to serialise the whole object?\r\n\r\nNote: I have all the `MTLJSONSerializing` methods implemented, including:\r\n\r\n```obj-c\r\n+ (NSValueTransformer *)dogsJSONTransformer {\r\n\r\n    return [MTLJSONAdapter dictionaryTransformerWithModelClass:Dog.class];\r\n}\r\n``` \r\nIs that maybe this method that is expecting to map a single `Dog` instead of an array of them?\r\nThanks in advance"},"comment":{"url":"https://api.github.com/repos/Mantle/Mantle/issues/comments/213352116","html_url":"https://github.com/Mantle/Mantle/issues/695#issuecomment-213352116","issue_url":"https://api.github.com/repos/Mantle/Mantle/issues/695","id":213352116,"user":{"login":"JanGorman","id":138166,"avatar_url":"https://avatars.githubusercontent.com/u/138166?v=3","gravatar_id":"","url":"https://api.github.com/users/JanGorman","html_url":"https://github.com/JanGorman","followers_url":"https://api.github.com/users/JanGorman/followers","following_url":"https://api.github.com/users/JanGorman/following{/other_user}","gists_url":"https://api.github.com/users/JanGorman/gists{/gist_id}","starred_url":"https://api.github.com/users/JanGorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanGorman/subscriptions","organizations_url":"https://api.github.com/users/JanGorman/orgs","repos_url":"https://api.github.com/users/JanGorman/repos","events_url":"https://api.github.com/users/JanGorman/events{/privacy}","received_events_url":"https://api.github.com/users/JanGorman/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T09:29:02Z","updated_at":"2016-04-22T09:29:02Z","body":"@crsantos Could you post some more code? I did something similar in the past and just tried your dog example:\r\n\r\n```objective-c\r\n@interface Dog : MTLModel\r\n@property(copy, nonatomic) NSString *dogName;\r\n- (instancetype)initWithName:(NSString *)name;\r\n@end\r\n\r\n@implementation Dog\r\n- (instancetype)initWithName:(NSString *)name {\r\n    self = [super init];\r\n    if (self) {\r\n        _dogName = name;\r\n    }\r\n    return self;\r\n}\r\n@end\r\n\r\n@interface User : MTLModel\r\n@property(copy, nonatomic) NSString *userId;\r\n@property(copy, nonatomic) NSArray<Dog *> *dogs;\r\n@end\r\n\r\n@implementation User\r\n@end\r\n```\r\n\r\nAnd then archiving/unarchiving:\r\n\r\n```objective-c\r\n    Dog *pluto = [[Dog alloc] initWithName: @\"pluto\"];\r\n    Dog *snoopy = [[Dog alloc] initWithName: @\"snoopy\"];\r\n    \r\n    NSArray *dogs = @[pluto, snoopy];\r\n    \r\n    User *user = [[User alloc] init];\r\n    user.userId = @\"abc\";\r\n    user.dogs = dogs;\r\n    \r\n    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:user];\r\n    \r\n    User *unarchivedUser = [NSKeyedUnarchiver unarchiveObjectWithData:data];\r\n    NSLog(@\"Unarchived: %@\", unarchivedUser);\r\n```\r\n\r\nwhich prints out\r\n\r\n```\r\nUnarchived: <User: 0x7f83634afa40> {\r\n    dogs =     (\r\n        \"<Dog: 0x7f836480d5a0> {\\n    dogName = pluto;\\n}\",\r\n        \"<Dog: 0x7f8364813860> {\\n    dogName = snoopy;\\n}\"\r\n    );\r\n    userId = abc;\r\n}\r\n```\r\n\r\nas you'd expect."}}