{"action":"created","issue":{"url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/21","labels_url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/21/comments","events_url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/21/events","html_url":"https://github.com/Roobiq/RBQFetchedResultsController/pull/21","id":82634439,"number":21,"title":"Fix bug","user":{"login":"yuuki1224","id":1756640,"avatar_url":"https://avatars.githubusercontent.com/u/1756640?v=3","gravatar_id":"","url":"https://api.github.com/users/yuuki1224","html_url":"https://github.com/yuuki1224","followers_url":"https://api.github.com/users/yuuki1224/followers","following_url":"https://api.github.com/users/yuuki1224/following{/other_user}","gists_url":"https://api.github.com/users/yuuki1224/gists{/gist_id}","starred_url":"https://api.github.com/users/yuuki1224/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuuki1224/subscriptions","organizations_url":"https://api.github.com/users/yuuki1224/orgs","repos_url":"https://api.github.com/users/yuuki1224/repos","events_url":"https://api.github.com/users/yuuki1224/events{/privacy}","received_events_url":"https://api.github.com/users/yuuki1224/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-29T23:53:27Z","updated_at":"2015-05-29T23:58:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/pulls/21","html_url":"https://github.com/Roobiq/RBQFetchedResultsController/pull/21","diff_url":"https://github.com/Roobiq/RBQFetchedResultsController/pull/21.diff","patch_url":"https://github.com/Roobiq/RBQFetchedResultsController/pull/21.patch"},"body":"I've found the bug when I write test of `RBQFetchedResultsController` class.\r\n\r\nWhen I stored date like below:\r\n\r\n![2015-05-29 15 21 57](https://cloud.githubusercontent.com/assets/1756640/7894642/5f9455c0-0622-11e5-9562-a9bda839c0ad.png)\r\n\r\nEven though section type is 2 types(`section 1` and `section 2`), but `self.fetchedResultsController numberOfSections` will return 10 because `[controllerCache.sections addObject:section];` will be called 10 times in `- createCacheWithRealm:cacheName:forFetchRequest:sectionNameKeyPath:` method."},"comment":{"url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/comments/106964420","html_url":"https://github.com/Roobiq/RBQFetchedResultsController/pull/21#issuecomment-106964420","issue_url":"https://api.github.com/repos/Roobiq/RBQFetchedResultsController/issues/21","id":106964420,"user":{"login":"bigfish24","id":1036685,"avatar_url":"https://avatars.githubusercontent.com/u/1036685?v=3","gravatar_id":"","url":"https://api.github.com/users/bigfish24","html_url":"https://github.com/bigfish24","followers_url":"https://api.github.com/users/bigfish24/followers","following_url":"https://api.github.com/users/bigfish24/following{/other_user}","gists_url":"https://api.github.com/users/bigfish24/gists{/gist_id}","starred_url":"https://api.github.com/users/bigfish24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigfish24/subscriptions","organizations_url":"https://api.github.com/users/bigfish24/orgs","repos_url":"https://api.github.com/users/bigfish24/repos","events_url":"https://api.github.com/users/bigfish24/events{/privacy}","received_events_url":"https://api.github.com/users/bigfish24/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T23:58:58Z","updated_at":"2015-05-29T23:58:58Z","body":"This is the expected behavior. The keyPath for the section names must either be the first sort in the fetchRequest or have the same ordering. Here is how Apple explains it for NSFetchedResultsController:\r\n\r\n>If this key path is not the same as that specified by the first sort descriptor in fetchRequest, they must generate the same relative orderings. For example, the first sort descriptor in fetchRequest might specify the key for a persistent property; sectionNameKeyPath might specify a key for a transient property derived from the persistent property."}}