Parse column value of class is always nil

While fetching object using query only certain columns are fetched and the rest is nil. I have also tried fetchIfNeededInBackgroundWithBlock but with no luck.

Query:

let query = PFQuery(className:"Order")
query.whereKey("buyerUser", equalTo: PFUser.currentUser()!)
query.findObjectsInBackgroundWithBlock { (orders: [PFObject]?, error: NSError?) -> Void in
    if(error == nil){
        print(orders?.first)
    }
}

Output:

Optional(<Order: 0x7ff778011940, objectId: KytyBZD9zV, localId: (null)> {
buyerUser = "<PFUser: 0x7ff77353e520, objectId: xxxxx, localId: (null)>";
charged = 1;
fulfilled = 0;
item = "<Item: 0x7ff778011dd0, objectId: GN277W4mO0, localId: (null)>";
shippingUser = "<PFUser: 0x7ff778012270, objectId: xxxx, localId: (null)>";
stripePaymentId = "xxxxxx";})

Order class in Parse Data Browser

订单类

If I try to access the transactionId with following code:

let order = orders?.first
print(order.objectForKey("transactionId"))

The result is always nil .

Please help.

Update

Attached is the Order class data in Parse. As all the rows have data and the object I have used have returned some data in other columns (buyerUser, charged) there is data in transactionId column of the object.

分析订单类数据


I can not see "transactionId" in the console message you posted - if key you are looking for is not present it will return nil

charged = 1; fulfilled = 0; item = ""; shippingUser = ""; stripePaymentId = "xxxxxx";})

Update: Server information and message in the console don'e match eq: Order: 0x7fb253fedc80, objectId: WrgiDFxZW6 which can not be located in the server data attached with question.

It can happen if your are referring different table in Parse SDK than the one you used in web(screen shot) - make sure you are refereeing same table in code and web.

链接地址: http://www.djcxy.com/p/88964.html

上一篇: 加快Python / Cython循环。

下一篇: 类的Parse列值始终为零