{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/152","labels_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/152/comments","events_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/152/events","html_url":"https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/152","id":104361106,"number":152,"title":"Swift v2 Error Handling","user":{"login":"adonoho","id":179204,"avatar_url":"https://avatars.githubusercontent.com/u/179204?v=3","gravatar_id":"","url":"https://api.github.com/users/adonoho","html_url":"https://github.com/adonoho","followers_url":"https://api.github.com/users/adonoho/followers","following_url":"https://api.github.com/users/adonoho/following{/other_user}","gists_url":"https://api.github.com/users/adonoho/gists{/gist_id}","starred_url":"https://api.github.com/users/adonoho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adonoho/subscriptions","organizations_url":"https://api.github.com/users/adonoho/orgs","repos_url":"https://api.github.com/users/adonoho/repos","events_url":"https://api.github.com/users/adonoho/events{/privacy}","received_events_url":"https://api.github.com/users/adonoho/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/labels/discussion","name":"discussion","color":"eeeeee"},{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/labels/enhancement","name":"enhancement","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"nlutsenko","id":606991,"avatar_url":"https://avatars.githubusercontent.com/u/606991?v=3","gravatar_id":"","url":"https://api.github.com/users/nlutsenko","html_url":"https://github.com/nlutsenko","followers_url":"https://api.github.com/users/nlutsenko/followers","following_url":"https://api.github.com/users/nlutsenko/following{/other_user}","gists_url":"https://api.github.com/users/nlutsenko/gists{/gist_id}","starred_url":"https://api.github.com/users/nlutsenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlutsenko/subscriptions","organizations_url":"https://api.github.com/users/nlutsenko/orgs","repos_url":"https://api.github.com/users/nlutsenko/repos","events_url":"https://api.github.com/users/nlutsenko/events{/privacy}","received_events_url":"https://api.github.com/users/nlutsenko/received_events","type":"User","site_admin":false},"milestone":null,"comments":12,"created_at":"2015-09-01T21:45:26Z","updated_at":"2015-09-02T14:19:04Z","closed_at":null,"body":"Gentlefolk,\r\n \r\nThe Swift v2 try-catch mechanism maps onto Objective-C quite well. Except when there is a shadowing problem.\r\n \r\nFor example:\r\n \r\n    - (BOOL)pinWithName:(NSString *)name error:(NSError **)error;\r\n\r\n \r\nwhich automatically maps into Swift v2 in [redacted] v7b6 headers as:\r\n \r\n    public func pinWithName(name: String, error: ()) throws\r\n \r\nIt should probably map as:\r\n\r\n    public func pinWithName(name: String) throws\r\n\r\nThe Objective-C method Is also commonly paired with this shortened form:\r\n \r\n    - (BOOL)pinWithName:(NSString *)name;\r\n \r\nWhich maps as: \r\n\r\n    public func pinWithName(name: String) -> Bool\r\n\r\nThis short method, I suspect, just calls the main one with a NULL for the NSError**. The signature for the short method is remarkably similar to the Swift throwing method. If I leave the short method in my Objective-C header, then errors ensue:\r\n\r\n    do { try location.pinWithName(kLocationPin)\r\n        updatePinnedLocations() // Add the locations to the user in the cloud.\r\n    }\r\n    catch let e as NSError { log.error(\"Local location save error: \\(e)\") }\r\n\r\nResults in the following compile time warning.\r\n\r\n    warning: no calls to throwing functions occur within 'try' expression\r\n           do { try location.pinWithName(kLocationPin)\r\n                ^\r\n \r\nObviously, the compiler has chosen the wrong signature. In my own code, where I express a similar pattern, I comment out the short method, then the app compiles just fine.\r\n\r\nWhat is the right way to fix the public API? In most things Swift, the answer would be to get rid of the short Objective-C method.\r\n \r\nOr is there a workaround to the above problem? In my own code, I have tried using the NS_SWIFT_NOTHROWS annotation on the long method signature. It allows me to retain my Swift v1.2 error handling code mostly without change.\r\n\r\nWhat would be the right solution for the Parse API?\r\n\r\nAnon,\r\nAndrew\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/comments/137097939","html_url":"https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/152#issuecomment-137097939","issue_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-iOS-OSX/issues/152","id":137097939,"user":{"login":"adonoho","id":179204,"avatar_url":"https://avatars.githubusercontent.com/u/179204?v=3","gravatar_id":"","url":"https://api.github.com/users/adonoho","html_url":"https://github.com/adonoho","followers_url":"https://api.github.com/users/adonoho/followers","following_url":"https://api.github.com/users/adonoho/following{/other_user}","gists_url":"https://api.github.com/users/adonoho/gists{/gist_id}","starred_url":"https://api.github.com/users/adonoho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adonoho/subscriptions","organizations_url":"https://api.github.com/users/adonoho/orgs","repos_url":"https://api.github.com/users/adonoho/repos","events_url":"https://api.github.com/users/adonoho/events{/privacy}","received_events_url":"https://api.github.com/users/adonoho/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T14:19:04Z","updated_at":"2015-09-02T14:19:04Z","body":"You may also want to examine this macro:\r\n\r\n    - (BOOL)canEvaluatePolicy:(LAPolicy)policy error:(NSError * __autoreleasing *)error __attribute__((swift_error(none)));\r\n"}}