I ask this in the context of a iOS / Swift app:
When retrieving with a query an object from Parse, I used to check for empty fields by checking them against nil. if != nil.... then do this etc etc....
Apparently, this is not the proper way to do this, because even if a field is empty on Parse, it is NOT considered nil by swift.
So what to to check for to determine if a field is empty or not, and for the various Parse supported types: strings, Number, Array.....?
Edit: there are answers for objective-c that don't work in swift where unless value is a boolean you MUST compare it against nil (which cause issue here) or something else to see if it exists or not.
You would use whereKeyExists:
Checkout the Parse documentation
If you want to retrieve objects that have a particular key set, you can use whereKeyExists. Conversely, if you want to retrieve objects without a particular key set, you can use whereKeyDoesNotExist.
// Finds objects that have the score set
[query whereKeyExists:@"score"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With