Reputation: 4075
In my swift app, I am sending mail to the registered mail ID which is register in parse.com. I searched in docs, Objective c code is having. I couldn't convert it into SWIFT. I am receiving error. My code is below.
//OBJECTIVE C
[PFCloud callFunctionInBackground:@"hello"
withParameters:@{}
block:^(NSString *result, NSError *error) {
if (!error) {
// result is @"Hello world!"
}
}];
//MY SWIFT CODING
PFCloud.callFunctionInBackground("hello", withParameters: {}, block: {(result: String, error: NSError)} )
//ERROR RECEIVING that conversion not happening.
Kindly guide me.
Upvotes: 0
Views: 719
Reputation: 1706
for swift 2.0 try this
PFCloud.callFunctionInBackground("GetUserIntrest", withParameters:nil) {
(result: AnyObject?, error: NSError?) -> Void in
if error == nil {
// result is "Hello world!"
}
}
Upvotes: 0
Reputation: 22343
You should change your syntax of the withParameter
tag. You need to use [:]
instead of {}
. Also change the type from the result to AnyObject!
I highly recommend you to check this developer guide of parse, where you find all the neccessary informations. Just choose "Swift" as the language to show. You can choose to show Objective-c or Swift sample code in this guide.
PFCloud.callFunctionInBackground("hello", withParameters:[:]) {
(result: AnyObject!, error: NSError!) -> Void in
if error == nil {
// result is "Hello world!"
}
}
Upvotes: 1