Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27143

Parse - NSNull null analog in Swift

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;

Upvotes: 2

Views: 439

Answers (1)

Sulthan
Sulthan

Reputation: 130102

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

Upvotes: 4

Related Questions