Swift 2.0 & twitter fabric update broken sendTwitterRequest

ios
swift

#1

Hello All,
I have updated to Xcode 7, swift 2.0 and also updated fabric twitter Framework today, sice I did it, sendTwitterRequest stopped to work with method error:

“Invalid conversion from throwing function of type ‘(_, _, _) throws -> Void’ to non-throwing function type ‘TWTRNetworkCompletion’ (aka ‘(Optional, Optional, Optional) -> ()’)”

What can I do with this issue? Before this code worked perfect:

UPD: I have noticed that funcition handler should support try catch syntax

>     func shareTwitterVideo(url: String, text: String) {

>             let uploadUrl = "https://upload.twitter.com/1.1/media/upload.json"
>             let updateUrl = "https://api.twitter.com/1.1/statuses/update.json"



>             let videoData = NSData(contentsOfFile: url)
>             let videoString = videoData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
>             let videoDataLength = NSNumber(integer: (videoData?.length)!).stringValue

>             var client = TWTRAPIClient()

>             var initError: NSError?
>             var message = ["status": self.imageDescription.text, "command" : "INIT", "media_type" : "video/m4v", "total_bytes" : videoDataLength]
>             let preparedRequest: NSURLRequest = client.URLRequestWithMethod("POST", URL: uploadUrl, parameters: message, error: &initError)
>             var  json: NSDictionary!



>             client.sendTwitterRequest(preparedRequest, completion: { (urlResponse: NSURLResponse?, responseData: NSData?, error: NSError?) -> Void in

>                 if error == nil {

>                     do {
>                       json = try NSJSONSerialization.JSONObjectWithData(responseData, options: .MutableContainers) as! NSDictionary
>                     } catch let error as NSError {
>                         print(error)
>                     }

>                     print(json)

>                     let mediaID = json.objectForKey("media_id_string") as! String

>                     client = Twitter.sharedInstance().APIClient
>                     var uploadError: NSError?

>                     message = ["command" : "APPEND", "media_id" : mediaID, "segment_index" : "0", "media" : videoString]
>                     let preparedRequest = client.URLRequestWithMethod("POST", URL: uploadUrl, parameters: message, error: &uploadError)
>                     client.sendTwitterRequest(preparedRequest, completion: { (urlResponse: NSURLResponse?, responseData: NSData?, error: NSError?) -> Void in
>                         if error == nil {
>                             client = Twitter.sharedInstance().APIClient
>                             var finalizeError: NSError?
>                             message = ["command":"FINALIZE", "media_id": mediaID]
>                             let preparedRequest = client.URLRequestWithMethod("POST", URL: uploadUrl, parameters: message, error: &finalizeError)
>                             client.sendTwitterRequest(preparedRequest, completion: { (urlResponse: NSURLResponse?, responseData: NSData?, error: NSError?) -> Void in
>                                 if error == nil {
>                                     client = Twitter.sharedInstance().APIClient
>                                     var sendError: NSError?
>                                     let message = ["status": text, "wrap_links": "true", "media_ids": mediaID]
>                                     _ = NSMutableDictionary(dictionary: message)
>                                     let preparedRequest = client.URLRequestWithMethod("POST", URL: updateUrl, parameters: message , error: &sendError)
>                                     client.sendTwitterRequest(preparedRequest, completion: { (urlResponse: NSURLResponse?, responseData: NSData?, error: NSError?) -> Void in

>                                     })
>                                 } else {
>                                     print("Command FINALIZE failed \n \(error!)")
>                                 }
>                             })
>                         } else {
>                             print("Command APPEND failed")
>                         }
>                     })
>                 } else {
>                     print("Command INIT failed")
>                 }
>             })


>         }




>         func shareTwitterImage(image: UIImage, text: String) {

>             if (Twitter.sharedInstance().sessionStore.session() != nil) {

>                 let urlMedia = "https://upload.twitter.com/1.1/media/upload.json"
>                 let urlStatus = "https://api.twitter.com/1.1/statuses/update.json"

>                 let imageData = UIImageJPEGRepresentation(image, 0.3)
>                 let imageString = imageData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)


>                 let params = [
>                     "media"  : imageString
>                 ]

>                 let client  = TWTRAPIClient()
>                 var error : NSError?
>                 let request  = client.URLRequestWithMethod("POST", URL: urlMedia, parameters: params, error: &error)

>                 var json : NSDictionary!

>                 client.sendTwitterRequest(request, completion: { (response, data, error) -> Void in

>                     do {
>                         json = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as! NSDictionary
>                     } catch let error as NSError {
>                         print(error)
>                     }


>                     if (json["media_id_string"] != nil) {

>                         print(json)
>                         print(response)

>                         let mediaId = json["media_id_string"] as! String
>                         let statParams = [
>                             "status" : text,
>                             "media_ids" : mediaId
>                         ]

>                         let statusReq = client.URLRequestWithMethod("POST", URL: urlStatus, parameters: statParams, error: &error)
>                         client.sendTwitterRequest(statusReq, completion: { (response, statusData, statusError) -> Void in
>                             if statusError != nil {
>                                 print(response)
>                             }
>                         })
>                     } else {
>                         print("media string is nil")
>                     }

>                 })
>             }

>         }

#2

fixed it. need to catch connectionError from hadler not new error object


#3