{"issue":{"state":"open","created_at":"2011-08-19T07:21:59Z","updated_at":"2011-11-28T23:00:53Z","user":{"gravatar_id":"d5743ef28991b38cf34feb84f5dd82a9","id":819705,"url":"https://api.github.com/users/tyrone-sudeium","avatar_url":"https://secure.gravatar.com/avatar/d5743ef28991b38cf34feb84f5dd82a9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"tyrone-sudeium"},"comments":6,"body":"Three major changes in this one:\r\n\r\n\r\nInverse relationships are more Core Data like\r\n-------------------------\r\n\r\nIn the case where you have, for example:\r\n\r\n    Employee has one Department\r\n    Department has many Employees\r\n\r\nIf you tried to do:\r\n`[anEmployee setDepartment: aDepartment];`\r\nIt would fail to set the inverse \"many\" relationship (i.e add `anEmployee` to the `employees` array).  I've made a few changes to the PONSO template to correct this behaviour.  I've taken steps to ensure that it won't infinite loop!\r\n\r\nFixed a memory leak when the \"many\" relationship in a one-to-many is Transient\r\n------------------------\r\n\r\nIn the case above, if it was configured as such:\r\n\r\n    Employee has one Department [Non-Transient]\r\n    Department has many Employees [Transient]\r\n\r\nEmployees would be added to an `NSArray`, and by default, `NSArray`s retain any objects added to them.  This results in an unexpected memory leak (since one would assume that making it transient, like for the \"one\" side, causes it to be \"assigned\").  I've fixed this by using a trick when creating the `NSMutableArray` (or `NSMutableSet`, see below) - using `CFArrayCreateMutable`, you can set the \"retain\" and \"release\" functions to `NULL` to prevent it from calling retain and release on added objects.  Since this makes use of the Toll-free bridge, it _will_ cause issues with ARC projects.\r\n\r\nNSSet-based PONSO Templates\r\n----------------------------------\r\n\r\nI've also added a sub-directory to the PONSO templates folder which is basically the same as the `NSArray` ones except it uses `NSSet` instead of `NSArray`.  This is particularly useful, since along with my changes to inverse relationships, with `NSArray`s, the following code would result in unexpected behaviour:\r\n`[anEmployee setDepartment: aDepartment];\r\n[anEmployee setDepartment: aDepartment];`\r\nYou'd end up with the `employees` array containing `anEmployee` twice, which may not be what the developer was expecting.  Using the `NSSet`-based templates gets around this issue since `NSSet`s only accept unique objects.","assignee":null,"id":1439077,"labels":[],"pull_request":{"patch_url":"https://github.com/rentzsch/mogenerator/pull/68.patch","html_url":"https://github.com/rentzsch/mogenerator/pull/68","diff_url":"https://github.com/rentzsch/mogenerator/pull/68.diff"},"number":68,"title":"PONSO: NSSet-based templates, improved inverse relationship logic","closed_at":null,"html_url":"https://github.com/rentzsch/mogenerator/issues/68","url":"https://api.github.com/repos/rentzsch/mogenerator/issues/68","milestone":null},"action":"created","comment":{"created_at":"2011-11-28T23:00:52Z","updated_at":"2011-11-28T23:00:52Z","user":{"gravatar_id":"4657022b56c5a4cc420c38ed5c99d413","id":2971,"url":"https://api.github.com/users/rentzsch","avatar_url":"https://secure.gravatar.com/avatar/4657022b56c5a4cc420c38ed5c99d413?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"rentzsch"},"body":"Nikita, I'll be pushing out a new version soonish. Merge Tyrone's stuff if you want it in the next release or just let me know it will sit this one out.","id":2909008,"url":"https://api.github.com/repos/rentzsch/mogenerator/issues/comments/2909008"}}