{"action":"created","issue":{"url":"https://api.github.com/repos/evermeer/EVReflection/issues/270","repository_url":"https://api.github.com/repos/evermeer/EVReflection","labels_url":"https://api.github.com/repos/evermeer/EVReflection/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/evermeer/EVReflection/issues/270/comments","events_url":"https://api.github.com/repos/evermeer/EVReflection/issues/270/events","html_url":"https://github.com/evermeer/EVReflection/issues/270","id":296526978,"number":270,"title":"XML - Crash on missing key","user":{"login":"Alarson93","id":16312918,"avatar_url":"https://avatars2.githubusercontent.com/u/16312918?v=4","gravatar_id":"","url":"https://api.github.com/users/Alarson93","html_url":"https://github.com/Alarson93","followers_url":"https://api.github.com/users/Alarson93/followers","following_url":"https://api.github.com/users/Alarson93/following{/other_user}","gists_url":"https://api.github.com/users/Alarson93/gists{/gist_id}","starred_url":"https://api.github.com/users/Alarson93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alarson93/subscriptions","organizations_url":"https://api.github.com/users/Alarson93/orgs","repos_url":"https://api.github.com/users/Alarson93/repos","events_url":"https://api.github.com/users/Alarson93/events{/privacy}","received_events_url":"https://api.github.com/users/Alarson93/received_events","type":"User","site_admin":false},"labels":[{"id":267023577,"url":"https://api.github.com/repos/evermeer/EVReflection/labels/fixed?","name":"fixed?","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-02-12T21:16:34Z","updated_at":"2018-02-16T06:01:18Z","closed_at":"2018-02-16T06:01:18Z","author_association":"NONE","body":"Current using the following:\r\n```\r\n    pod 'EVReflection/Realm', :git => 'https://github.com/evermeer/EVReflection.git', :tag => '5.4.3'\r\n    pod 'EVReflection/XML', :git => 'https://github.com/evermeer/EVReflection.git', :tag => '5.4.3'\r\n```\r\n\r\nExample XML:\r\n```\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\r\n<xmldata xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n\r\n<filename>MyFileName.pdf</filename>\r\n\r\n</xmldata>\r\n```\r\n\r\nExample object:\r\nclass Result: Object, EVReflectable {\r\n```\r\n    @objc dynamic var filename: String?\r\n}\r\n```\r\n\r\nWhen EVR attempts to turn the XML into a Dictionary, the `<xmldata xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">` line is interpreted as a field.\r\nIts key is \"__name\" and value is \"xmldata\". \r\nThis occurs on line 20 of EVReflectable+XMLDictionary.\r\n\r\nI figured this wouldn't be a big deal. I'm not including the \"__name\" key as a property so I assume that key-value pair will simply be discarded. But, to my surprise, EVR attempts to set the data to the appropriate (non-existant) property. This occurs in the `setPropertiesfromDictionary` function because \"__name\" shows up in the keyMapping list.\r\n\r\nI dived into `getKeyMapping` to figure out why this would be. \r\nIt would seem that you include the unknown mappings. Specifically the following:\r\n```\r\nif !isAdded {\r\n    keyMapping.append((item.key as? String, item.key as? String))\r\n}\r\n```\r\n\r\nWe are including a key that does not have a corresponding property on a Realm object. This appears to cause a crash in RLMObjectBase.\r\n\r\nIn summary:\r\nI am combining the Realm and XML extensions. A crash occurs when a key exists in the XML that does not have a complimentary property in the object."},"comment":{"url":"https://api.github.com/repos/evermeer/EVReflection/issues/comments/366151566","html_url":"https://github.com/evermeer/EVReflection/issues/270#issuecomment-366151566","issue_url":"https://api.github.com/repos/evermeer/EVReflection/issues/270","id":366151566,"user":{"login":"evermeer","id":130834,"avatar_url":"https://avatars1.githubusercontent.com/u/130834?v=4","gravatar_id":"","url":"https://api.github.com/users/evermeer","html_url":"https://github.com/evermeer","followers_url":"https://api.github.com/users/evermeer/followers","following_url":"https://api.github.com/users/evermeer/following{/other_user}","gists_url":"https://api.github.com/users/evermeer/gists{/gist_id}","starred_url":"https://api.github.com/users/evermeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evermeer/subscriptions","organizations_url":"https://api.github.com/users/evermeer/orgs","repos_url":"https://api.github.com/users/evermeer/repos","events_url":"https://api.github.com/users/evermeer/events{/privacy}","received_events_url":"https://api.github.com/users/evermeer/received_events","type":"User","site_admin":false},"created_at":"2018-02-16T06:01:18Z","updated_at":"2018-02-16T06:01:18Z","author_association":"OWNER","body":"Great to hear that you have it working. \r\nIt's good to know that it can really work when going from XML to Realm. "}}
{"actor":{"display_login":"evermeer"}}