Closed schan93 closed 9 years ago
I would first make sure your fields are all unwrapped and are not still optionals. Text fields should be optional because we are blind to knowing if the user has entered anything into them. You should unwrap these values (try using if let) and then call the function with the non-optional values
You are also missing the audience, but I do realize this is not a required parameter. Could be something to try and play around with though.
I'm not sure that you can do what you are trying to do in swift with regards to the completion handler. I believe you can make something called a type alias for a completion handler that you want to keep reusing, but I dont have much experience with those. I just typed out the completion handler when it asked for it. XCode6 has a great feature when the user has highlighted a parameter that is a completion handler, they can simply press enter and the completion handler will be laid out by Xcode. Not sure if this was the answer you want but hope this helps
that worked for me
You can implement your code or call a function in the If error != nil { mySuccessfunc () // this funtion will be called when the payment has been sent successfully }
Hi, are there any examples of how to implement the
Venmo.sharedInstance().sendPaymentTo
method in Swift? The following is the implementation I want to use for the sendPaymentTo method. Any help would be appreciated.Venmo.sharedInstance().sendPaymentTo(recipientHandle: self.toTextField.text, amount: self.amountTextField.text.floatValue*100, note: self.noteTextField.text, completionHandler: self.noteTextField.text, <#VENTransactionCompletionHandler!##(VENTransaction!, Bool, NSError!) -> Void#>)
Below is an example of how I tried to make a completion handler in Swift but it doesn't seem to be working when I call the function:
func handler(completion: (transaction: VENTransactionCompletionHandler, result: Bool, error: NSError?) -> Void){ }
And when I try to call the
sendPaymentTo
method like so, I get an incorrect argument list:handler{ (transaction, result, error) -> Void in { Venmo.sharedInstance().sendPaymentTo(recipientHandle: self.toTextField.text, amount: self.amountTextField.text.floatValue*100, note, completionHandler: self.noteTextField.text, completionHandler: transaction) }}
If anyone could help me, that'd be great. Thanks!