1
votes

I am doing a query and I am checking to see if the value in the column "Parent", which is a pointer, is equal to a string, newLogObjectId. I obviously cannot do this since a pointer and a string are a different value type, (returns nil). How do I compare a string to a string in a pointer?

    //A string, for example, "MCeKMyxRIt"
    let newLogObjectId = objectIdArray[markerIndex]

    let query1 = PFQuery(className: "ComparablePhotos")
    //"Parent" is a pointer referencing an objectId in another class.  "newLogObjectId" is a string  How do I check to see if the String of Parent is equal to newLogObjectId, a string?
    query1.whereKey("Parent", equalTo:newLogObjectId)

enter image description here

1

1 Answers

1
votes

Pointers in Parse don't point to a value, they point to a class (a PFObject). So it looks like your pointer named Parent is pointing to the Parse class NewLog. I'm assuming then the string you are wanting to check is a field in the class NewLog. Also, to include the pointer in the query, use query1.includeKey("PointerName"). Try this:

let newLogObjectId = objectIdArray[markerIndex]

let query1 = PFQuery(className: "ComparablePhotos")
query1.includeKey("Parent")
query1.findObjectsInBackgroundWithBlock({ (objects: [AnyObject]?, error: NSError?) -> Void in
    if (error == nil){
        if let comparablePhotos = objects as? [PFObject]{
            for photo in comparablePhotos {
                if let parentPointer:PFObject = photo["Parent"] as? PFObject{
                    if(parentPointer["columnWithString"] as! String == newLogObjectID){
                        // Do something
                    }
                }
            }
        }
    }else{
        println(error)
    }

})