Home > Software design >  Parse - NSNull null analog in Swift
Parse - NSNull null analog in Swift

Time:09-16

How to convert this objective c code to Swift:

PFQuery *query = [PFQuery queryWithClassName:@"Review"];
[query whereKey:@"comment" notEqualTo:[NSNull null]];

when I simple put:

query.whereKey("comment", notEqualTo: nil)

Xcode throw build error:

'nil' is not compatible with expected argument type 'Any'

Technically I understand that I can't simple put nil there, but I did not found any helpful links with analog [NSNull null]

The method I call looks like this:

- (instancetype)whereKey:(NSString *)key equalTo:(id)object;

CodePudding user response:

You should be able to use NSNull() directly to represent the NSNull singleton instance.

  • Related