iosobjective-cparse-platformpfquerypffile

Filtering undefined files in PFQuery


I'm using Parse as a backend for storing image-based news items. Each news item has an image file. Some image files are 'undefined' and some have jpegs. I have an iOS app front end which shows news items in a PFQueryTableViewController. In the QueryForTable, I'd like to filter out records with undefined files.

I've tried this with no joy:

    - (PFQuery *)queryForTable {
        PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
        [query orderByDescending:@"EntryTime"];
        [query whereKey:@"Image" notEqualTo:@"undefined"];
        return query;
    }

And also:

    [query whereKey:@"Image" notEqualTo:@"null"];

Anyone know what the right way to treat 'undefined' files is?

Thanks!


Solution

  • This worked.

        [query whereKeyExists:@"Image"];
    

    in

        - (PFQuery *)queryForTable {
                PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
                [query orderByDescending:@"EntryTime"];
                [query whereKeyExists:@"Image"];
                return query;
            }