{"action":"opened","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/3857","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3857/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3857/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3857/events","html_url":"https://github.com/realm/realm-cocoa/issues/3857","id":165001398,"number":3857,"title":"Nested objects schemas are not initialized without explicitly calling defaultRealm","user":{"login":"viktorasl","id":3721061,"avatar_url":"https://avatars.githubusercontent.com/u/3721061?v=3","gravatar_id":"","url":"https://api.github.com/users/viktorasl","html_url":"https://github.com/viktorasl","followers_url":"https://api.github.com/users/viktorasl/followers","following_url":"https://api.github.com/users/viktorasl/following{/other_user}","gists_url":"https://api.github.com/users/viktorasl/gists{/gist_id}","starred_url":"https://api.github.com/users/viktorasl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viktorasl/subscriptions","organizations_url":"https://api.github.com/users/viktorasl/orgs","repos_url":"https://api.github.com/users/viktorasl/repos","events_url":"https://api.github.com/users/viktorasl/events{/privacy}","received_events_url":"https://api.github.com/users/viktorasl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-12T06:10:44Z","updated_at":"2016-07-12T06:10:44Z","closed_at":null,"body":"\r\n## Goals\r\n\r\nIt is a simple issue (odd that it was not raised yet). Without explicitly calling `[RLMRealm defaultRealm]` nested objects schemas are not initialized and exception is thrown trying to initialize object with value.\r\n\r\n## Actual Results\r\n\r\nhttps://github.com/viktorasl/Realm-RLMLinkingObjects/blob/master/Realm-RLMLinkingObjects/ViewController.m#L42\r\n\r\nLet's say there is a class `EventFooType` which objects have declared properties of `RLMObject` subclass `EventToken`. When trying to initialize `[EventFooType initWithValue:@{...}]` exception is thrown that `EventToken` is not persistent in realm.\r\n\r\nI added a breakpoint in the `- (RLMObjectSchema *)objectForKeyedSubscript:(__unsafe_unretained id<NSCopying> const)className` method and printed out `_objectSchemaByName` so if `[RLMRealm defaultRealm]` was not explicitly called then schema is missing nested objects schemas:\r\n\r\n```\r\n{\r\n    EventFooType = \"EventFooType {\\n\\tidentifier {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = YES;\\n\\t\\tisPrimary = YES;\\n\\t\\toptional = NO;\\n\\t}\\n\\tname {\\n\\t\\ttype = string;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = YES;\\n\\t}\\n\\tfooIntProperty {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = NO;\\n\\t}\\n\\ttoken {\\n\\t\\ttype = object;\\n\\t\\tobjectClassName = EventToken;\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = YES;\\n\\t}\\n}\";\r\n}\r\n```\r\nif it was explicitly called then:\r\n```\r\n{\r\n    EventBarType = \"EventBarType {\\n\\tidentifier {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = YES;\\n\\t\\tisPrimary = YES;\\n\\t\\toptional = NO;\\n\\t}\\n\\tbarIntProperty {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = NO;\\n\\t}\\n\\ttoken {\\n\\t\\ttype = object;\\n\\t\\tobjectClassName = EventToken;\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = YES;\\n\\t}\\n}\";\r\n    EventFooType = \"EventFooType {\\n\\tidentifier {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = YES;\\n\\t\\tisPrimary = YES;\\n\\t\\toptional = NO;\\n\\t}\\n\\tname {\\n\\t\\ttype = string;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = YES;\\n\\t}\\n\\tfooIntProperty {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = NO;\\n\\t}\\n\\ttoken {\\n\\t\\ttype = object;\\n\\t\\tobjectClassName = EventToken;\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = YES;\\n\\t}\\n}\";\r\n    EventToken = \"EventToken {\\n\\tidentifier {\\n\\t\\ttype = int;\\n\\t\\tobjectClassName = (null);\\n\\t\\tlinkOriginPropertyName = (null);\\n\\t\\tindexed = YES;\\n\\t\\tisPrimary = YES;\\n\\t\\toptional = NO;\\n\\t}\\n\\tfooEvents {\\n\\t\\ttype = linking objects;\\n\\t\\tobjectClassName = EventFooType;\\n\\t\\tlinkOriginPropertyName = token;\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = NO;\\n\\t}\\n\\tbarEvents {\\n\\t\\ttype = linking objects;\\n\\t\\tobjectClassName = EventBarType;\\n\\t\\tlinkOriginPropertyName = token;\\n\\t\\tindexed = NO;\\n\\t\\tisPrimary = NO;\\n\\t\\toptional = NO;\\n\\t}\\n}\";\r\n}\r\n```\r\n\r\n## Version of Realm and Tooling\r\nRealm version: 1.0.1\r\nXcode version: 7.3.1\r\niOS/OSX version: 9.0\r\nDependency manager + version: Cocoapods 1.0.1\r\n"}}
{"actor":{"display_login":"viktorasl"}}