2

How can i convert this javascript data to ios compatible data and put it in a dictionary, when i do something like this newCustomer["cvc_check"] etc nothing comes up i get a nil, l am trying to get data from parse PFCloud.callFunctioninBackground which is calling a stripe.com api to get those results

func hasToken(token: STPToken!) {

var parameters = ["cardToken":token.tokenId,
                  "objectId":PFUser.currentUser().objectId]

    PFCloud.callFunctionInBackground("createCustomer", withParameters:parameters) {
        (results: AnyObject!, error: NSError!) -> Void in
        if !error {

            var newCustomer = results as Dictionary<String, AnyObject>
            println(newCustomer["cvc_check"]) // This gives me a nil

            self.successfulPayment()
        } else {
            let message = error.userInfo["error"] as NSString
            self.hasError("\(message) Please try agains.")
        }
    }

my Screenshot

mavusane
  • 247
  • 1
  • 2
  • 8

1 Answers1

0

I think the problem is with the line:

var newCustomer = results as Dictionary<String, AnyObject>

As you said in your comment, results is an Array, so this line should be:

var newCustomer = results as Array<Dictionary<String, AnyObject>>

Does that help?

Dave Weston
  • 6,527
  • 1
  • 29
  • 44