{"action":"created","issue":{"url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/80","labels_url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/80/comments","events_url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/80/events","html_url":"https://github.com/Alterplay/APAddressBook/issues/80","id":92107591,"number":80,"title":"Filtering other fields besides phones (Swift)","user":{"login":"mplaczek","id":703391,"avatar_url":"https://avatars.githubusercontent.com/u/703391?v=3","gravatar_id":"","url":"https://api.github.com/users/mplaczek","html_url":"https://github.com/mplaczek","followers_url":"https://api.github.com/users/mplaczek/followers","following_url":"https://api.github.com/users/mplaczek/following{/other_user}","gists_url":"https://api.github.com/users/mplaczek/gists{/gist_id}","starred_url":"https://api.github.com/users/mplaczek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mplaczek/subscriptions","organizations_url":"https://api.github.com/users/mplaczek/orgs","repos_url":"https://api.github.com/users/mplaczek/repos","events_url":"https://api.github.com/users/mplaczek/events{/privacy}","received_events_url":"https://api.github.com/users/mplaczek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-30T14:21:09Z","updated_at":"2015-06-30T14:33:17Z","closed_at":null,"body":"I'm trying to filter my contacts to remove those without an email address\r\n where the example below works as expected for phone entries:\r\n```swift\r\n    self.addressBook.filterBlock = {(contact: APContact!) -> Bool in\r\n          return contact.phones.count > 0\r\n        }\r\n```\r\nThe following code returns \"fatal error: unexpectedly found nil while unwrapping an Optional value\"\r\n```swift\r\n    self.addressBook.filterBlock = {(contact: APContact!) -> Bool in\r\n          return contact.emails.count > 0\r\n        }\r\n```\r\nHow should the emails filter be implemented to avoid this error? I assume the [AnyObject]! emails and phones arrays contain different types so they should be treated differently, however the solution is not readily apparent to my noob eyes! "},"comment":{"url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/comments/117208812","html_url":"https://github.com/Alterplay/APAddressBook/issues/80#issuecomment-117208812","issue_url":"https://api.github.com/repos/Alterplay/APAddressBook/issues/80","id":117208812,"user":{"login":"belkevich","id":1284917,"avatar_url":"https://avatars.githubusercontent.com/u/1284917?v=3","gravatar_id":"","url":"https://api.github.com/users/belkevich","html_url":"https://github.com/belkevich","followers_url":"https://api.github.com/users/belkevich/followers","following_url":"https://api.github.com/users/belkevich/following{/other_user}","gists_url":"https://api.github.com/users/belkevich/gists{/gist_id}","starred_url":"https://api.github.com/users/belkevich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belkevich/subscriptions","organizations_url":"https://api.github.com/users/belkevich/orgs","repos_url":"https://api.github.com/users/belkevich/repos","events_url":"https://api.github.com/users/belkevich/events{/privacy}","received_events_url":"https://api.github.com/users/belkevich/received_events","type":"User","site_admin":false},"created_at":"2015-06-30T14:33:17Z","updated_at":"2015-06-30T14:33:17Z","body":"Looks like problem in Objective-C to Swift data type transfer. I hope it'll fixed with nullability support in next release. But I'm not sure.\r\nFor now, you can add check for `contact.phones != nil` before call `count` property.\r\nPlease, write here does it help or not"}}