-
Initializes the query with a class name.
Declaration
Objective-C
- (nonnull instancetype)initWithClassName:(nonnull NSString *)className;Swift
init(className: String)Parameters
classNameThe class name.
-
Returns a
PFQueryfor a given class.Declaration
Objective-C
+ (nonnull instancetype)queryWithClassName:(nonnull NSString *)className;Parameters
classNameThe class to query on.
Return Value
A
PFQueryobject. -
Creates a PFQuery with the constraints given by predicate.
The following types of predicates are supported:
- Simple comparisons such as
=,!=,<,>,<=,>=, andBETWEENwith a key and a constant. - Containment predicates, such as
x IN {1, 2, 3}. - Key-existence predicates, such as
x IN SELF. - BEGINSWITH expressions.
- Compound predicates with
AND,OR, andNOT. - SubQueries with
key IN %@, subquery.
The following types of predicates are NOT supported:
- Aggregate operations, such as
ANY,SOME,ALL, orNONE. - Regular expressions, such as
LIKE,MATCHES,CONTAINS, orENDSWITH. - Predicates comparing one key to another.
Complex predicates with many ORed clauses.
Declaration
Objective-C
+ (nonnull instancetype)queryWithClassName:(nonnull NSString *)className predicate:(nullable NSPredicate *)predicate;Swift
convenience init(className: String, predicate: NSPredicate?)Parameters
classNameThe class to query on.
predicateThe predicate to create conditions from.
- Simple comparisons such as
-
The class name to query for.
Declaration
Objective-C
@property (nonatomic, strong) NSString *_Nonnull parseClassName;Swift
var parseClassName: String { get set }
-
Make the query include
PFObjects that have a reference stored at the provided key.This has an effect similar to a join. You can use dot notation to specify which fields in the included object are also fetch.
Declaration
Objective-C
- (nonnull instancetype)includeKey:(nonnull NSString *)key;Swift
func includeKey(_ key: String) -> SelfParameters
keyThe key to load child
PFObjects for.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Make the query include
PFObjects that have a reference stored at the provided keys.Declaration
Objective-C
- (nonnull instancetype)includeKeys:(nonnull NSArray<NSString *> *)keys;Swift
func includeKeys(_ keys: [String]) -> SelfParameters
keysThe keys to load child
PFObjects for.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Make the query include all
PFObjects that have a reference.Declaration
Objective-C
- (nonnull instancetype)includeAll;Swift
func includeAll() -> SelfReturn Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Make the query restrict the fields of the returned
PFObjects to exclude the provided key.If this is called multiple times, then all of the keys specified in each of the calls will be excluded.
Declaration
Objective-C
- (nonnull instancetype)excludeKey:(nonnull NSString *)key;Swift
func excludeKey(_ key: String) -> SelfParameters
keyThe key to exclude in the result.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Make the query restrict the fields of the returned
PFObjects to exclude the provided keys.If this is called multiple times, then all of the keys specified in each of the calls will be excluded.
Declaration
Objective-C
- (nonnull instancetype)excludeKeys:(nonnull NSArray<NSString *> *)keys;Swift
func excludeKeys(_ keys: [String]) -> SelfParameters
keysThe keys to exclude in the result.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Make the query restrict the fields of the returned
PFObjects to include only the provided keys.If this is called multiple times, then all of the keys specified in each of the calls will be included.
Declaration
Objective-C
- (nonnull instancetype)selectKeys:(nonnull NSArray<NSString *> *)keys;Swift
func selectKeys(_ keys: [String]) -> SelfParameters
keysThe keys to include in the result.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint that requires a particular key exists.
Declaration
Objective-C
- (nonnull instancetype)whereKeyExists:(nonnull NSString *)key;Swift
func whereKeyExists(_ key: String) -> SelfParameters
keyThe key that should exist.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint that requires a key not exist.
Declaration
Objective-C
- (nonnull instancetype)whereKeyDoesNotExist:(nonnull NSString *)key;Swift
func whereKeyDoesNotExist(_ key: String) -> SelfParameters
keyThe key that should not exist.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be equal to the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key equalTo:(nonnull id)object;Swift
func whereKey(_ key: String, equalTo object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that must be equalled.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be less than the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key lessThan:(nonnull id)object;Swift
func whereKey(_ key: String, lessThan object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that provides an upper bound.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key lessThanOrEqualTo:(nonnull id)object;Swift
func whereKey(_ key: String, lessThanOrEqualTo object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that must be equalled.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be greater than the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key greaterThan:(nonnull id)object;Swift
func whereKey(_ key: String, greaterThan object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that must be equalled.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key greaterThanOrEqualTo:(nonnull id)object;Swift
func whereKey(_ key: String, greaterThanOrEqualTo object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that must be equalled.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key notEqualTo:(nonnull id)object;Swift
func whereKey(_ key: String, notEqualTo object: Any) -> SelfParameters
keyThe key to be constrained.
objectThe object that must not be equalled.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint for finding string values that contain a provided string using Full Text Search
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key matchesText:(nonnull NSString *)text;Swift
func whereKey(_ key: String, matchesText text: String) -> SelfParameters
keyThe key to be constrained.
textthe substring that the value must contain.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object to be contained in the provided array.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key containedIn:(nonnull NSArray *)array;Swift
func whereKey(_ key: String, containedIn array: [Any]) -> SelfParameters
keyThe key to be constrained.
arrayThe possible values for the key’s object.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s object not be contained in the provided array.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key notContainedIn:(nonnull NSArray *)array;Swift
func whereKey(_ key: String, notContainedIn array: [Any]) -> SelfParameters
keyThe key to be constrained.
arrayThe list of values the key’s object should not be.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s array contains every element of the provided array.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key containsAllObjectsInArray:(nonnull NSArray *)array;Swift
func whereKey(_ key: String, containsAllObjectsIn array: [Any]) -> SelfParameters
keyThe key to be constrained.
arrayThe array of values to search for.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Adds a constraint to the query that requires a particular key’s value to be contained by the provided list of values. Get objects where all array elements match
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key containedBy:(nonnull NSArray *)array;Swift
func whereKey(_ key: String, containedBy array: [Any]) -> SelfParameters
keyThe key to be constrained.
arrayThe array of values to search for.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Add a constraint to the query that requires a particular key’s coordinates (specified via
PFGeoPoint) be near a reference point.Distance is calculated based on angular distance on a sphere. Results will be sorted by distance from reference point.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key nearGeoPoint:(nonnull PFGeoPoint *)geopoint;Swift
func whereKey(_ key: String, nearGeoPoint geopoint: PFGeoPoint) -> SelfParameters
keyThe key to be constrained.
geopointThe reference point represented as a
PFGeoPoint.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
PFGeoPoint) be near a reference point and within the maximum distance specified (in miles).Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key nearGeoPoint:(nonnull PFGeoPoint *)geopoint withinMiles:(double)maxDistance;Swift
func whereKey(_ key: String, nearGeoPoint geopoint: PFGeoPoint, withinMiles maxDistance: Double) -> SelfParameters
keyThe key to be constrained.
geopointThe reference point represented as a
PFGeoPoint.maxDistanceMaximum distance in miles.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
PFGeoPoint) be near a reference point and within the maximum distance specified (in kilometers).Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key nearGeoPoint:(nonnull PFGeoPoint *)geopoint withinKilometers:(double)maxDistance;Swift
func whereKey(_ key: String, nearGeoPoint geopoint: PFGeoPoint, withinKilometers maxDistance: Double) -> SelfParameters
keyThe key to be constrained.
geopointThe reference point represented as a
PFGeoPoint.maxDistanceMaximum distance in kilometers.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
PFGeoPoint) be near a reference point and within the maximum distance specified (in radians). Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key nearGeoPoint:(nonnull PFGeoPoint *)geopoint withinRadians:(double)maxDistance;Swift
func whereKey(_ key: String, nearGeoPoint geopoint: PFGeoPoint, withinRadians maxDistance: Double) -> SelfParameters
keyThe key to be constrained.
geopointThe reference point as a
PFGeoPoint.maxDistanceMaximum distance in radians.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
PFGeoPoint) be contained within a given rectangular geographic bounding box.Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key withinGeoBoxFromSouthwest:(nonnull PFGeoPoint *)southwest toNortheast:(nonnull PFGeoPoint *)northeast;Swift
func whereKey(_ key: String, withinGeoBoxFromSouthwest southwest: PFGeoPoint, toNortheast northeast: PFGeoPoint) -> SelfParameters
keyThe key to be constrained.
southwestThe lower-left inclusive corner of the box.
northeastThe upper-right inclusive corner of the box.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates be contained within and on the bounds of a given polygon Supports closed and open (last point is connected to first) paths. (Requires [email protected])
Polygon must have at least 3 points
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key withinPolygon:(nonnull NSArray<PFGeoPoint *> *)points;Swift
func whereKey(_ key: String, withinPolygon points: [PFGeoPoint]) -> SelfParameters
keyThe key to be constrained.
pointsThe polygon points as an Array of
PFGeoPoint‘s.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint to the query that requires a particular key’s coordinates that contains a
PFGeoPoint(Requires [email protected])Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key polygonContains:(nonnull PFGeoPoint *)point;Swift
func whereKey(_ key: String, polygonContains point: PFGeoPoint) -> SelfParameters
keyThe key to be constrained.
pointReturn Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Add a regular expression constraint for finding string values that match the provided regular expression.
Warning
This may be slow for large datasets.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key matchesRegex:(nonnull NSString *)regex;Swift
func whereKey(_ key: String, matchesRegex regex: String) -> SelfParameters
keyThe key that the string to match is stored in.
regexThe regular expression pattern to match.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a regular expression constraint for finding string values that match the provided regular expression.
Warning
This may be slow for large datasets.
i- Case insensitive searchm- Search across multiple lines of input
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key matchesRegex:(nonnull NSString *)regex modifiers:(nullable NSString *)modifiers;Swift
func whereKey(_ key: String, matchesRegex regex: String, modifiers: String?) -> SelfParameters
keyThe key that the string to match is stored in.
regexThe regular expression pattern to match.
modifiersAny of the following supported PCRE modifiers:
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint for finding string values that contain a provided substring.
Warning
This will be slow for large datasets.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key containsString:(nullable NSString *)substring;Swift
func whereKey(_ key: String, contains substring: String?) -> SelfParameters
keyThe key that the string to match is stored in.
substringThe substring that the value must contain.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint for finding string values that start with a provided prefix.
This will use smart indexing, so it will be fast for large datasets.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key hasPrefix:(nullable NSString *)prefix;Swift
func whereKey(_ key: String, hasPrefix prefix: String?) -> SelfParameters
keyThe key that the string to match is stored in.
prefixThe substring that the value must start with.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint for finding string values that end with a provided suffix.
Warning
This will be slow for large datasets.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key hasSuffix:(nullable NSString *)suffix;Swift
func whereKey(_ key: String, hasSuffix suffix: String?) -> SelfParameters
keyThe key that the string to match is stored in.
suffixThe substring that the value must end with.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Returns a
PFQuerythat is theorof the passed in queries.Declaration
Objective-C
+ (nonnull instancetype)orQueryWithSubqueries: (nonnull NSArray<PFQuery *> *)queries;Swift
class func orQuery(withSubqueries queries: [PFQuery<PFObject>]) -> SelfParameters
queriesThe list of queries to or together.
Return Value
An instance of
PFQuerythat is theorof the passed in queries. -
Returns a
PFQuerythat is theandof the passed in queries.Declaration
Objective-C
+ (nonnull instancetype)andQueryWithSubqueries: (nonnull NSArray<PFQuery *> *)queries;Swift
class func andQuery(withSubqueries queries: [PFQuery<PFObject>]) -> SelfParameters
queriesThe list of queries to and together.
Return Value
An instance of
PFQuerythat is theandof the passed in queries. -
Adds a constraint that requires that a key’s value matches a value in another key in objects returned by a sub query.
Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key matchesKey:(nonnull NSString *)otherKey inQuery:(nonnull PFQuery *)query;Swift
func whereKey(_ key: String, matchesKey otherKey: String, in query: PFQuery<PFObject>) -> SelfParameters
keyThe key that the value is stored.
otherKeyThe key in objects in the returned by the sub query whose value should match.
queryThe query to run.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Adds a constraint that requires that a key’s value
NOTmatch a value in another key in objects returned by a sub query.Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key doesNotMatchKey:(nonnull NSString *)otherKey inQuery:(nonnull PFQuery *)query;Swift
func whereKey(_ key: String, doesNotMatchKey otherKey: String, in query: PFQuery<PFObject>) -> SelfParameters
keyThe key that the value is stored.
otherKeyThe key in objects in the returned by the sub query whose value should match.
queryThe query to run.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint that requires that a key’s value matches a
PFQueryconstraint.Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key matchesQuery:(nonnull PFQuery *)query;Swift
func whereKey(_ key: String, matchesQuery query: PFQuery<PFObject>) -> SelfParameters
keyThe key that the value is stored in
queryThe query the value should match
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Add a constraint that requires that a key’s value to not match a
PFQueryconstraint.Declaration
Objective-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key doesNotMatchQuery:(nonnull PFQuery *)query;Swift
func whereKey(_ key: String, doesNotMatch query: PFQuery<PFObject>) -> SelfParameters
keyThe key that the value is stored in
queryThe query the value should not match
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Sort the results in ascending order with the given key.
Declaration
Objective-C
- (nonnull instancetype)orderByAscending:(nonnull NSString *)key;Swift
func order(byAscending key: String) -> SelfParameters
keyThe key to order by.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Additionally sort in ascending order by the given key.
The previous keys provided will precedence over this key.
Declaration
Objective-C
- (nonnull instancetype)addAscendingOrder:(nonnull NSString *)key;Swift
func addAscendingOrder(_ key: String) -> SelfParameters
keyThe key to order by.
-
Sort the results in descending order with the given key.
Declaration
Objective-C
- (nonnull instancetype)orderByDescending:(nonnull NSString *)key;Swift
func order(byDescending key: String) -> SelfParameters
keyThe key to order by.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Additionally sort in descending order by the given key.
The previous keys provided will precedence over this key.
Declaration
Objective-C
- (nonnull instancetype)addDescendingOrder:(nonnull NSString *)key;Swift
func addDescendingOrder(_ key: String) -> SelfParameters
keyThe key to order by.
-
Sort the results using a given sort descriptor.
Warning
If a
sortDescriptorhas customselectororcomparator- they aren’t going to be used.Declaration
Objective-C
- (nonnull instancetype)orderBySortDescriptor: (nonnull NSSortDescriptor *)sortDescriptor;Swift
func order(by sortDescriptor: NSSortDescriptor) -> SelfParameters
sortDescriptorThe
NSSortDescriptorto use to sort the results of the query.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Sort the results using a given array of sort descriptors.
Warning
If a
sortDescriptorhas customselectororcomparator- they aren’t going to be used.Declaration
Objective-C
- (nonnull instancetype)orderBySortDescriptors: (nullable NSArray<NSSortDescriptor *> *)sortDescriptors;Swift
func order(by sortDescriptors: [NSSortDescriptor]?) -> SelfParameters
sortDescriptorsAn array of
NSSortDescriptorobjects to use to sort the results of the query.Return Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Gets a
PFObjectasynchronously and calls the given block with the result.Warning
This method mutates the query. It will reset limit to
1, skip to0and remove all conditions, leaving onlyobjectId.Declaration
Objective-C
- (nonnull BFTask<PFGenericObject> *)getObjectInBackgroundWithId: (nonnull NSString *)objectId;Swift
func getObjectInBackground(withId objectId: String) -> Any!Parameters
objectIdThe id of the object that is being requested.
Return Value
The task, that encapsulates the work being done.
-
Gets a
PFObjectasynchronously and calls the given block with the result.Warning
This method mutates the query. It will reset limit to
1, skip to0and remove all conditions, leaving onlyobjectId.Declaration
Objective-C
- (void)getObjectInBackgroundWithId:(nonnull NSString *)objectId block: (nullable void (^)(PFGenericObject _Nullable, NSError *_Nullable))block;Swift
func getObjectInBackground(withId objectId: String, block: ((PFGenericObject?, (any Error)?) -> Void)? = nil)Parameters
objectIdThe id of the object that is being requested.
blockThe block to execute. The block should have the following argument signature:
^(NSArray *object, NSError *error)
-
Deprecated
Use [PFUser query] instead.
@deprecated Please use [PFUser query] instead.
Declaration
Objective-C
+ (nonnull instancetype)queryForUser;Swift
class func forUser() -> Self
-
Finds objects asynchronously and sets the
NSArrayofPFObjectobjects as a result of the task.Declaration
Objective-C
- (nonnull BFTask<NSArray<PFGenericObject> *> *)findObjectsInBackground;Swift
func findObjectsInBackground() -> Any!Return Value
The task, that encapsulates the work being done.
-
Finds objects asynchronously and calls the given block with the results.
Declaration
Objective-C
- (void)findObjectsInBackgroundWithBlock: (nullable PFQueryArrayResultBlock)block;Swift
func findObjectsInBackground() async throws -> [PFGenericObject]Parameters
blockThe block to execute. It should have the following argument signature:
^(NSArray *objects, NSError *error)
-
Gets an object asynchronously and sets it as a result of the task.
Warning
This method mutates the query. It will reset the limit to
1.Declaration
Objective-C
- (nonnull BFTask<PFGenericObject> *)getFirstObjectInBackground;Swift
func getFirstObjectInBackground() -> Any!Return Value
The task, that encapsulates the work being done.
-
Gets an object asynchronously and calls the given block with the result.
Warning
This method mutates the query. It will reset the limit to
1.Declaration
Objective-C
- (void)getFirstObjectInBackgroundWithBlock: (nullable void (^)(PFGenericObject _Nullable, NSError *_Nullable))block;Swift
func firstObjectInBackground() async throws -> PFGenericObjectParameters
blockThe block to execute. It should have the following argument signature:
^(PFObject *object, NSError *error).resultwill beniliferroris set OR no object was found matching the query.errorwill benilifresultis set OR if the query succeeded, but found no results.
-
Counts objects asynchronously and sets
NSNumberwith count as a result of the task.Declaration
Objective-C
- (nonnull BFTask<NSNumber *> *)countObjectsInBackground;Swift
func countObjectsInBackground() -> Any!Return Value
The task, that encapsulates the work being done.
-
Counts objects asynchronously and calls the given block with the counts.
Declaration
Objective-C
- (void)countObjectsInBackgroundWithBlock:(nullable PFIntegerResultBlock)block;Swift
func countObjectsInBackground() async throws -> Int32Parameters
blockThe block to execute. It should have the following argument signature:
^(int count, NSError *error)
-
Cancels the current network request (if any). Ensures that callbacks won’t be called.
Declaration
Objective-C
- (void)cancel;Swift
func cancel()
-
A limit on the number of objects to return. The default limit is
100, with a maximum of 1000 results being returned at a time.Warning
If you are callingfindObjectswithlimit = 1, you may find it easier to usegetFirstinstead.Declaration
Objective-C
@property (nonatomic) NSInteger limit;Swift
var limit: Int { get set } -
The number of objects to skip before returning any.
Declaration
Objective-C
@property (nonatomic) NSInteger skip;Swift
var skip: Int { get set }
-
The cache policy to use for requests.
Not allowed when Pinning is enabled.
See
fromLocalDatastoreSee
fromPinSee
fromPinWithName:Declaration
Objective-C
@property (nonatomic) PFCachePolicy cachePolicy;Swift
var cachePolicy: PFCachePolicy { get set } -
The age after which a cached value will be ignored
Declaration
Objective-C
@property (nonatomic) NSTimeInterval maxCacheAge;Swift
var maxCacheAge: TimeInterval { get set } -
Returns whether there is a cached result for this query.
@result
YESif there is a cached result for this query, otherwiseNO.Declaration
Objective-C
@property (nonatomic, readonly) BOOL hasCachedResult;Swift
var hasCachedResult: Bool { get } -
Clears the cached result for this query. If there is no cached result, this is a noop.
Declaration
Objective-C
- (void)clearCachedResult;Swift
func clearCachedResult() -
Clears the cached results for all queries.
Declaration
Objective-C
+ (void)clearAllCachedResults;Swift
class func clearAllCachedResults()
-
Change the source of this query to all pinned objects.
Warning
Requires Local Datastore to be enabled.
See
cachePolicy
Declaration
Objective-C
- (nonnull instancetype)fromLocalDatastore;Swift
func fromLocalDatastore() -> SelfReturn Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Change the source of this query to the default group of pinned objects.
Warning
Requires Local Datastore to be enabled.
See
PFObjectDefaultPin
See
cachePolicy
Declaration
Objective-C
- (nonnull instancetype)fromPin;Swift
func fromPin() -> SelfReturn Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Change the source of this query to a specific group of pinned objects.
Warning
Requires Local Datastore to be enabled.
See
PFObjectDefaultPin
See
cachePolicy
Declaration
Objective-C
- (nonnull instancetype)fromPinWithName:(nullable NSString *)name;Swift
func fromPin(withName name: String?) -> SelfParameters
nameThe pinned group.
Return Value
The same instance of
PFQueryas the receiver. This allows method chaining. -
Ignore ACLs when querying from the Local Datastore.
This is particularly useful when querying for objects with Role based ACLs set on them.
Warning
Requires Local Datastore to be enabled.
Declaration
Objective-C
- (nonnull instancetype)ignoreACLs;Swift
func ignoreACLs() -> SelfReturn Value
The same instance of
PFQueryas the receiver. This allows method chaining.
-
Whether or not performance tracing should be done on the query.
Warning
This should not be set toYESin most cases.Declaration
Objective-C
@property (nonatomic) BOOL trace;Swift
var trace: Bool { get set }
-
Deprecated
Please use
PFQuery.-getObjectInBackgroundWithId:block:instead.Gets a
PFObjectasynchronously.This mutates the PFQuery. It will reset limit to
1, skip to0and remove all conditions, leaving onlyobjectId.@deprecated Please use
PFQuery.-getObjectInBackgroundWithId:block:instead.Declaration
Objective-C
- (void)getObjectInBackgroundWithId:(nonnull NSString *)objectId target:(nullable id)target selector:(nullable SEL)selector;Swift
func getObjectInBackground(withId objectId: String, target: Any?, selector: Selector?)Parameters
objectIdThe id of the object being requested.
targetThe target for the callback selector.
selectorThe selector for the callback. It should have the following signature:
(void)callbackWithResult:(id)result error:(NSError *)error. Result will benilif error is set and vice versa.
-
Deprecated
Please use
PFQuery.-findObjectsInBackgroundWithBlock:instead.Finds objects asynchronously and calls the given callback with the results.
@deprecated Please use
PFQuery.-findObjectsInBackgroundWithBlock:instead.Declaration
Objective-C
- (void)findObjectsInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector;Swift
func findObjectsInBackground(withTarget target: Any?, selector: Selector?)Parameters
targetThe object to call the selector on.
selectorThe selector to call. It should have the following signature:
(void)callbackWithResult:(id)result error:(NSError *)error. Result will benilif error is set and vice versa.
-
Deprecated
Please use
PFQuery.-getFirstObjectInBackgroundWithBlock:instead.Gets an object asynchronously and calls the given callback with the results.
Warning
This method mutates the query. It will reset the limit to
1.@deprecated Please use
PFQuery.-getFirstObjectInBackgroundWithBlock:instead.Declaration
Objective-C
- (void)getFirstObjectInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector;Swift
func getFirstObjectInBackground(withTarget target: Any?, selector: Selector?)Parameters
targetThe object to call the selector on.
selectorThe selector to call. It should have the following signature:
(void)callbackWithResult:(PFObject *)result error:(NSError *)error.resultwill beniliferroris set OR no object was found matching the query.errorwill benilifresultis set OR if the query succeeded, but found no results.
-
Deprecated
Please use
PFQuery.-countObjectsInBackgroundWithBlock:instead.Counts objects asynchronously and calls the given callback with the count.
@deprecated Please use
PFQuery.-countObjectsInBackgroundWithBlock:instead.Declaration
Objective-C
- (void)countObjectsInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector;Swift
func countObjectsInBackground(withTarget target: Any?, selector: Selector?)Parameters
targetThe object to call the selector on.
selectorThe selector to call. It should have the following signature:
(void)callbackWithResult:(NSNumber *)result error:(NSError *)error.
-
Returns a
PFObjectwith a given class and id.Declaration
Objective-C
+ (nullable PFGenericObject)getObjectOfClass:(nonnull NSString *)objectClass objectId:(nonnull NSString *)objectId;Parameters
objectClassThe class name for the object that is being requested.
objectIdThe id of the object that is being requested.
Return Value
The
PFObjectif found. Returnsnilif the object isn’t found, or if there was an error. -
Returns a
PFObjectwith a given class and id and sets an error if necessary.Declaration
Objective-C
+ (nullable PFGenericObject)getObjectOfClass:(nonnull NSString *)objectClass objectId:(nonnull NSString *)objectId error: (NSError *_Nullable *_Nullable)error;Swift
class func getObjectOfClass(_ objectClass: String, objectId: String) throws -> PFGenericObjectParameters
objectClassThe class name for the object that is being requested.
objectIdThe id of the object that is being requested.
errorPointer to an
NSErrorthat will be set if necessary.Return Value
The
PFObjectif found. Returnsnilif the object isn’t found, or if there was anerror. -
Returns a
PFObjectwith the given id.Warning
This method mutates the query. It will reset limit to
1, skip to0and remove all conditions, leaving onlyobjectId.Declaration
Objective-C
- (nullable PFGenericObject)getObjectWithId:(nonnull NSString *)objectId;Parameters
objectIdThe id of the object that is being requested.
Return Value
The
PFObjectif found. Returns nil if the object isn’t found, or if there was an error. -
Returns a
PFObjectwith the given id and sets an error if necessary.Warning
This method mutates the query. It will reset limit to
1, skip to0and remove all conditions, leaving onlyobjectId.Declaration
Objective-C
- (nullable PFGenericObject)getObjectWithId:(nonnull NSString *)objectId error: (NSError *_Nullable *_Nullable)error;Swift
func getObjectWithId(_ objectId: String) throws -> PFGenericObjectParameters
objectIdThe id of the object that is being requested.
errorPointer to an
NSErrorthat will be set if necessary.Return Value
The
PFObjectif found. Returns nil if the object isn’t found, or if there was an error.
-
Returns a PFUser with a given class and id and sets an error if necessary.
Declaration
Objective-C
+ (nullable PFUser *)getUserObjectWithId:(nonnull NSString *)objectId error:(NSError *_Nullable *_Nullable)error;Swift
class func getUserObject(withId objectId: String) throws -> PFUserParameters
objectIdThe id of the object that is being requested.
errorPointer to an NSError that will be set if necessary. @result The PFUser if found. Returns nil if the object isn’t found, or if there was an error.
-
Finds objects synchronously based on the constructed query.
Declaration
Objective-C
- (nullable NSArray<PFGenericObject> *)findObjects;Return Value
Returns an array of
PFObjectobjects that were found. -
Finds objects synchronously based on the constructed query and sets an error if there was one.
Declaration
Objective-C
- (nullable NSArray<PFGenericObject> *)findObjects: (NSError *_Nullable *_Nullable)error;Swift
func findObjects() throws -> [PFGenericObject]Parameters
errorPointer to an
NSErrorthat will be set if necessary.Return Value
Returns an array of
PFObjectobjects that were found.
-
Gets an object synchronously based on the constructed query.
Warning
This method mutates the query. It will reset the limit to
1.Declaration
Objective-C
- (nullable PFGenericObject)getFirstObject;Return Value
Returns a
PFObject, ornilif none was found. -
Gets an object synchronously based on the constructed query and sets an error if any occurred.
Warning
This method mutates the query. It will reset the limit to
1.Declaration
Objective-C
- (nullable PFGenericObject)getFirstObject:(NSError *_Nullable *_Nullable)error;Swift
func getFirstObject() throws -> PFGenericObjectParameters
errorPointer to an
NSErrorthat will be set if necessary.Return Value
Returns a
PFObject, ornilif none was found.
-
Counts objects synchronously based on the constructed query.
Declaration
Objective-C
- (NSInteger)countObjects;Return Value
Returns the number of
PFObjectobjects that match the query, or-1if there is an error. -
Counts objects synchronously based on the constructed query and sets an error if there was one.
Declaration
Objective-C
- (NSInteger)countObjects:(NSError *_Nullable *_Nullable)error;Swift
func countObjects(_ error: NSErrorPointer) -> IntParameters
errorPointer to an
NSErrorthat will be set if necessary.Return Value
Returns the number of
PFObjectobjects that match the query, or-1if there is an error.
View on GitHub
Install in Dash