1

When i call the PFcloud function from normal it return the correct count how ever when i call it with selector, the selector call back function is not fired,

Appreciate if any can can point to me what is the mistake in my code.

Working block - it print out the count successfully

        PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], block: {
        (result: AnyObject!, error: NSError!) -> Void in
        if ( error === nil) {
            NSLog("Booking Count call back: \(result) ")
        }
        else if (error != nil) {
            NSLog("error in helloWorld: \(error.userInfo)")
        }
    })

Not Working block (Selector ) - selector function not called

    PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], target: self, selector: "block:")


func block (result: AnyObject!, error: NSError!) {
    if ( error === nil) {
        NSLog("Booking Count from Block: \(result) ")
    }
    else if (error != nil) {
        NSLog("error in helloWorld: \(error.userInfo)")
    }
}

Question:

I need someone to highlight to my the error in writing the selector function as the selector function is not called.

Thanks

2 Answers 2

0

Your method has two parameters so you need a selector like blockWithResult:error:

Sign up to request clarification or add additional context in comments.

Comments

-3

You're not using the right Swift syntax for selector. Try this instead:

PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], target: self, selector: Selector("block:error:"))

func block(result: AnyObject!, error: NSError!) {
    if ( error === nil) {
        NSLog("Booking Count from Block: \(result) ")
    }
    else if (error != nil) {
        NSLog("error in helloWorld: \(error.userInfo)")
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.