{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/1787","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1787/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1787/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1787/events","html_url":"https://github.com/realm/realm-cocoa/issues/1787","id":70508612,"number":1787,"title":"Subclassing does not work","user":{"login":"lewissk","id":886496,"avatar_url":"https://avatars.githubusercontent.com/u/886496?v=3","gravatar_id":"","url":"https://api.github.com/users/lewissk","html_url":"https://github.com/lewissk","followers_url":"https://api.github.com/users/lewissk/followers","following_url":"https://api.github.com/users/lewissk/following{/other_user}","gists_url":"https://api.github.com/users/lewissk/gists{/gist_id}","starred_url":"https://api.github.com/users/lewissk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewissk/subscriptions","organizations_url":"https://api.github.com/users/lewissk/orgs","repos_url":"https://api.github.com/users/lewissk/repos","events_url":"https://api.github.com/users/lewissk/events{/privacy}","received_events_url":"https://api.github.com/users/lewissk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T20:42:48Z","updated_at":"2015-04-23T20:48:57Z","closed_at":"2015-04-23T20:48:57Z","body":"I am converting from CoreData to Realm.io I did a little experiment to see how Realm.io handles situations where I need to have subclasses of a class that is an RLMObject.  This is posted on SO as well: https://stackoverflow.com/questions/29832985/how-to-do-abstract-entities-in-realm-io-in-swift\r\n\r\nExample project here: https://github.com/lewissk/RealmTest\r\n\r\nModel\r\n\r\n    import Realm\r\n\r\n    @objc enum RecurrenceEnum : Int {\r\n        case Daily = 1\r\n        case Weekly = 2\r\n        case Monthly = 3\r\n    }\r\n    \r\n    class Challenge: RLMObject {\r\n        dynamic var title = \"\"\r\n    }\r\n    \r\n    class TotalCountChallenge: Challenge {\r\n        dynamic var totalCountGoal: Int = 0\r\n    }\r\n    \r\n    class RecurringChallenge: Challenge {\r\n        dynamic var recurranceType: RecurrenceEnum = .Daily\r\n        dynamic var totalCountGoal: Int = 0\r\n    }\r\n  \r\nWhen I save either a TotalCountChallenge or A RecurringChallenge it reports no errors but when I go to query for challenges by title I don't get anything back.\r\n\r\nQuery from my ViewController\r\n\r\n    // Query using an NSPredicate object\r\n    let predicate = NSPredicate(format: \"title BEGINSWITH %@\", \"Booya\")\r\n    var challenges = Challenge.objectsWithPredicate(predicate)\r\n    \r\n    if challenges == nil || challenges.count == 0 {\r\n        let tcChallenge = TotalCountChallenge()\r\n        tcChallenge.title = \"Booya Total Count Challenge\"\r\n        tcChallenge.totalCountGoal = 1_000_000\r\n        \r\n        let rChallenge = RecurringChallenge()\r\n        rChallenge.title = \"Booya Recurring Challenge\"\r\n        rChallenge.recurranceType = .Weekly\r\n        rChallenge.totalCountGoal = 2_000_000\r\n        \r\n        let realm = RLMRealm.defaultRealm()\r\n        // You only need to do this once (per thread)\r\n        \r\n        // Add to the Realm inside a transaction\r\n        realm.beginWriteTransaction()\r\n        realm.addObject(tcChallenge)\r\n        realm.addObject(rChallenge)\r\n        realm.commitWriteTransaction()\r\n    }\r\n    \r\n    challenges = Challenge.objectsWithPredicate(predicate)\r\n    if challenges != nil && challenges.count > 0 {\r\n        for challenge in challenges {\r\n            let c = challenge as! Challenge\r\n            println(\"\\(c.title)\")\r\n        }\r\n    } else {\r\n        println(\"No Challenges found\")\r\n    }\r\n        \r\n    challenges = TotalCountChallenge.objectsWithPredicate(predicate)\r\n    if challenges != nil && challenges.count > 0 {\r\n        for challenge in challenges {\r\n            let c = challenge as! Challenge\r\n            println(\"TotalCountChallenge: \\(c.title)\")\r\n        }\r\n    } else {\r\n        println(\"No Total Count Challenges found\")\r\n    }\r\n        \r\n    challenges = RecurringChallenge.objectsWithPredicate(predicate)\r\n    if challenges != nil && challenges.count > 0 {\r\n        for challenge in challenges {\r\n            let c = challenge as! Challenge\r\n            println(\"RecurringChallenge \\(c.title)\")\r\n        }\r\n    } else {\r\n        println(\"No Recurring Challenges found\")\r\n    }\r\n\r\nOutput\r\n\r\n    No Challenges found\r\n    TotalCountChallenge: Booya Total Count Challenge\r\n    RecurringChallenge Booya Recurring Challenge\r\n\r\nWhen I look at the database using the Browse Tool provided by Realm I see that there is only 1 TotalCountChallenge and 1 RecurringChallenge and there are no Challenges\r\n\r\n![enter image description here][1]\r\n\r\n\r\nIs there a way to do this?\r\n\r\nHere is a link to the code in github: [lewissk/RealmTest][2]\r\n\r\n\r\n  [1]: http://i.stack.imgur.com/Gr2Sd.png\r\n  [2]: https://github.com/lewissk/RealmTest"},"comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/95714776","html_url":"https://github.com/realm/realm-cocoa/issues/1787#issuecomment-95714776","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1787","id":95714776,"user":{"login":"lewissk","id":886496,"avatar_url":"https://avatars.githubusercontent.com/u/886496?v=3","gravatar_id":"","url":"https://api.github.com/users/lewissk","html_url":"https://github.com/lewissk","followers_url":"https://api.github.com/users/lewissk/followers","following_url":"https://api.github.com/users/lewissk/following{/other_user}","gists_url":"https://api.github.com/users/lewissk/gists{/gist_id}","starred_url":"https://api.github.com/users/lewissk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewissk/subscriptions","organizations_url":"https://api.github.com/users/lewissk/orgs","repos_url":"https://api.github.com/users/lewissk/repos","events_url":"https://api.github.com/users/lewissk/events{/privacy}","received_events_url":"https://api.github.com/users/lewissk/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T20:48:57Z","updated_at":"2015-04-23T20:48:57Z","body":"duplicate of #1109 "}}