Reputation: 676
Per Firebase Firestore docs, in order to query a collection where an array contains a certain value, you'd do this:
citiesRef.whereField("regions", arrayContains: "west_coast")
Only when I try to write that in Swift 4, I get the following error:
Argument labels '(_:, arrayContains:)' do not match any available overloads
Looking at the available overloads yields the following:
Query whereField(field: String, isEqualTo: Any)
Query whereField(path: FieldPath, isEqualTo: Any)
Query whereField(field: String, isLessThan: Any)
Query whereField(path: FieldPath, isLessThan: Any)
Query whereField(field: String, isGreaterThan: Any)
Query whereField(path: FieldPath, isGreaterThan: Any)
Query whereField(field: String, isLessThanOrEqualTo: Any)
Query whereField(path: FieldPath, isLessThanOrEqualTo: Any)
Query whereField(field: String, isGreaterThanOrEqualTo: Any)
Query whereField(path: FieldPath, isGreaterThanOrEqualTo: Any)
Nothing in there about arrays or contains. Are the docs out of date? What am I missing? Docs found here
My Podfile:
platform :ios, '9.0'
target 'Appname' do
use_frameworks!
# Pods for Appname
pod ‘Firebase/Core’
pod ‘Firebase/Auth’
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Firebase/Invites'
pod 'SwiftGifOrigin', '~> 1.6'
pod 'Kingfisher', '~> 4.0'
pod 'AudioKit', '~> 4.0'
pod 'KSTokenView', '~> 4.0'
pod 'ReachabilitySwift'
pod 'ZFTokenField'
pod 'SlackTextViewController'
pod 'RealmSwift'
target 'AppnameTests' do
inherit! :search_paths
# Pods for testing
end
target 'AppnameUITests' do
inherit! :search_paths
# Pods for testing
end
end
Upvotes: 0
Views: 1447
Reputation: 317968
arrayContains support was released in 5.5.0 of the Firestore pod. Make sure you are using that version or later. Read the release notes here.
Upvotes: 3