Inherits from NSObject
Declared in PFQuery.h

Overview

A class that defines a query that is used to query for PFObjects.

Tasks

Creating a Query for a Class

Adding Basic Constraints

  • – includeKey:

    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.

  • – selectKeys:

    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.

  • – whereKeyExists:

    Add a constraint that requires a particular key exists.

  • – whereKeyDoesNotExist:

    Add a constraint that requires a key not exist.

  • – whereKey:equalTo:

    Add a constraint to the query that requires a particular key’s object to be equal to the provided object.

  • – whereKey:lessThan:

    Add a constraint to the query that requires a particular key’s object to be less than the provided object.

  • – whereKey:lessThanOrEqualTo:

    Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.

  • – whereKey:greaterThan:

    Add a constraint to the query that requires a particular key’s object to be greater than the provided object.

  • – whereKey:greaterThanOrEqualTo:

    Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.

  • – whereKey:notEqualTo:

    Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.

  • – whereKey:containedIn:

    Add a constraint to the query that requires a particular key’s object to be contained in the provided array.

  • – whereKey:notContainedIn:

    Add a constraint to the query that requires a particular key’s object not be contained in the provided array.

  • – whereKey:containsAllObjectsInArray:

    Add a constraint to the query that requires a particular key’s array contains every element of the provided array.

Adding Location Constraints

  • – whereKey:nearGeoPoint:

    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.

  • – whereKey:nearGeoPoint:withinMiles:

    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.

  • – whereKey:nearGeoPoint:withinKilometers:

    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.

  • – whereKey:nearGeoPoint:withinRadians:

    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.

  • – whereKey:withinGeoBoxFromSouthwest:toNortheast:

    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.

Adding String Constraints

  • – whereKey:matchesRegex:

    Add a regular expression constraint for finding string values that match the provided regular expression.
    This may be slow for large datasets.

  • – whereKey:matchesRegex:modifiers:

    Add a regular expression constraint for finding string values that match the provided regular expression.
    This may be slow for large datasets.

  • – whereKey:containsString:

    Add a constraint for finding string values that contain a provided substring.
    This will be slow for large datasets.

  • – whereKey:hasPrefix:

    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.

  • – whereKey:hasSuffix:

    Add a constraint for finding string values that end with a provided suffix.
    This will be slow for large datasets.

Adding Subqueries

  • + orQueryWithSubqueries:

    Returns a PFQuery that is the or of the passed in PFQuerys.

  • – whereKey:matchesKey:inQuery:

    Adds a constraint that requires that a key’s value matches a value in another key
    in objects returned by a sub query.

  • – whereKey:doesNotMatchKey:inQuery:

    Adds a constraint that requires that a key’s value NOT match a value in another key
    in objects returned by a sub query.

  • – whereKey:matchesQuery:

    Add a constraint that requires that a key’s value matches a PFQuery constraint.
    This only works where the key’s values are PFObjects or arrays of PFObjects.

  • – whereKey:doesNotMatchQuery:

    Add a constraint that requires that a key’s value to not match a PFQuery constraint.
    This only works where the key’s values are PFObjects or arrays of PFObjects.

Sorting

Getting Objects by ID

Getting User Objects

Getting all Matches for a Query

Getting the First Match in a Query

Counting the Matches in a Query

Cancelling a Query

  • – cancel

    Cancels the current network request (if any). Ensures that callbacks won’t be called.

Paginating Results

  •   limit

    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.

    property
  •   skip

    The number of objects to skip before returning any.

    property

Controlling Caching Behavior

Advanced Settings

  •   trace

    Whether or not performance tracing should be done on the query.
    This should not be set in most cases.

    property

Properties

cachePolicy

The cache policy to use for requests.

@property (readwrite, assign) PFCachePolicy cachePolicy

Discussion

The cache policy to use for requests.

Declared In

PFQuery.h

limit

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.

@property (nonatomic) NSInteger limit

Discussion

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.

Note: If you are calling findObject with limit=1, you may find it easier to use getFirst instead.

Declared In

PFQuery.h

parseClassName

The class name to query for

@property (nonatomic, retain) NSString *parseClassName

Discussion

The class name to query for

Declared In

PFQuery.h

skip

The number of objects to skip before returning any.

@property (nonatomic) NSInteger skip

Discussion

The number of objects to skip before returning any.

Declared In

PFQuery.h

trace

Whether or not performance tracing should be done on the query.
This should not be set in most cases.

@property (nonatomic, assign) BOOL trace

Discussion

Whether or not performance tracing should be done on the query.
This should not be set in most cases.

Declared In

PFQuery.h

Class Methods

clearAllCachedResults

Clears the cached results for all queries.

+ (void)clearAllCachedResults

Discussion

Clears the cached results for all queries.

Declared In

PFQuery.h

getObjectOfClass:objectId:

Returns a PFObject with a given class and id.

+ (PFObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId

Parameters

objectClass

The class name for the object that is being requested.

objectId

The id of the object that is being requested.

Return Value

The PFObject if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFObject with a given class and id.

Declared In

PFQuery.h

getObjectOfClass:objectId:error:

Returns a PFObject with a given class and id and sets an error if necessary.

+ (PFObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId error:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

The PFObject if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFObject with a given class and id and sets an error if necessary.

Declared In

PFQuery.h

getUserObjectWithId:

Returns a PFUser with a given id.

+ (PFUser *)getUserObjectWithId:(NSString *)objectId

Parameters

objectId

The id of the object that is being requested.

Return Value

The PFUser if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFUser with a given id.

Declared In

PFQuery.h

getUserObjectWithId:error:

Returns a PFUser with a given class and id and sets an error if necessary.

+ (PFUser *)getUserObjectWithId:(NSString *)objectId error:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

The PFUser if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFUser with a given class and id and sets an error if necessary.

Declared In

PFQuery.h

orQueryWithSubqueries:

Returns a PFQuery that is the or of the passed in PFQuerys.

+ (PFQuery *)orQueryWithSubqueries:(NSArray *)queries

Parameters

queries

The list of queries to or together.

Return Value

a PFQuery that is the or of the passed in PFQuerys.

Discussion

Returns a PFQuery that is the or of the passed in PFQuerys.

Declared In

PFQuery.h

queryForUser

Deprecated. Please use [PFUser query] instead.

+ (PFQuery *)queryForUser

Discussion

Deprecated. Please use [PFUser query] instead.

Declared In

PFQuery.h

queryWithClassName:

Returns a PFQuery for a given class.

+ (PFQuery *)queryWithClassName:(NSString *)className

Parameters

className

The class to query on.

Return Value

A PFQuery object.

Discussion

Returns a PFQuery for a given class.

Declared In

PFQuery.h

queryWithClassName:predicate:

Creates a PFQuery with the constraints given by predicate.

+ (PFQuery *)queryWithClassName:(NSString *)className predicate:(NSPredicate *)predicate

Discussion

Creates a PFQuery with the constraints given by predicate.

The following types of predicates are supported:
* Simple comparisons such as =, !=, <, >, <=, >=, and BETWEEN with 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, and NOT.
* SubQueries with “key IN %@”, subquery.

The following types of predicates are NOT supported:
* Aggregate operations, such as ANY, SOME, ALL, or NONE.
* Regular expressions, such as LIKE, MATCHES, CONTAINS, or ENDSWITH.
* Predicates comparing one key to another.
* Complex predicates with many ORed clauses.

Declared In

PFQuery.h

Instance Methods

addAscendingOrder:

Also sort in ascending order by the given key. The previous keys provided will
precedence over this key.

- (void)addAscendingOrder:(NSString *)key

Parameters

key

The key to order bye

Discussion

Also sort in ascending order by the given key. The previous keys provided will
precedence over this key.

Declared In

PFQuery.h

addDescendingOrder:

Also sort in descending order by the given key. The previous keys provided will
precedence over this key.

- (void)addDescendingOrder:(NSString *)key

Parameters

key

The key to order bye

Discussion

Also sort in descending order by the given key. The previous keys provided will
precedence over this key.

Declared In

PFQuery.h

cancel

Cancels the current network request (if any). Ensures that callbacks won’t be called.

- (void)cancel

Discussion

Cancels the current network request (if any). Ensures that callbacks won’t be called.

Declared In

PFQuery.h

clearCachedResult

Clears the cached result for this query. If there is no cached result, this is a noop.

- (void)clearCachedResult

Discussion

Clears the cached result for this query. If there is no cached result, this is a noop.

Declared In

PFQuery.h

countObjects

Counts objects based on the constructed query.

- (NSInteger)countObjects

Return Value

Returns the number of PFObjects that match the query, or -1 if there is an error.

Discussion

Counts objects based on the constructed query.

Declared In

PFQuery.h

countObjects:

Counts objects based on the constructed query and sets an error if there was one.

- (NSInteger)countObjects:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns the number of PFObjects that match the query, or -1 if there is an error.

Discussion

Counts objects based on the constructed query and sets an error if there was one.

Declared In

PFQuery.h

countObjectsInBackgroundWithBlock:

Counts objects asynchronously and calls the given block with the counts.

- (void)countObjectsInBackgroundWithBlock:(PFIntegerResultBlock)block

Parameters

block

The block to execute. The block should have the following argument signature:
(int count, NSError *error)

Discussion

Counts objects asynchronously and calls the given block with the counts.

Declared In

PFQuery.h

countObjectsInBackgroundWithTarget:selector:

Counts objects asynchronously and calls the given callback with the count.

- (void)countObjectsInBackgroundWithTarget:(id)target selector:(SEL)selector

Parameters

target

The object to call the selector on.

selector

The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error.

Discussion

Counts objects asynchronously and calls the given callback with the count.

Declared In

PFQuery.h

findObjects

Finds objects based on the constructed query.

- (NSArray *)findObjects

Return Value

Returns an array of PFObjects that were found.

Discussion

Finds objects based on the constructed query.

Declared In

PFQuery.h

findObjects:

Finds objects based on the constructed query and sets an error if there was one.

- (NSArray *)findObjects:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns an array of PFObjects that were found.

Discussion

Finds objects based on the constructed query and sets an error if there was one.

Declared In

PFQuery.h

findObjectsInBackgroundWithBlock:

Finds objects asynchronously and calls the given block with the results.

- (void)findObjectsInBackgroundWithBlock:(PFArrayResultBlock)block

Parameters

block

The block to execute. The block should have the following argument signature:(NSArray objects, NSError error)

Discussion

Finds objects asynchronously and calls the given block with the results.

Declared In

PFQuery.h

findObjectsInBackgroundWithTarget:selector:

Finds objects asynchronously and calls the given callback with the results.

- (void)findObjectsInBackgroundWithTarget:(id)target selector:(SEL)selector

Parameters

target

The object to call the selector on.

selector

The selector to call. It should have the following signature: (void)callbackWithResult:(NSArray )result error:(NSError )error. result will be nil if error is set and vice versa.

Discussion

Finds objects asynchronously and calls the given callback with the results.

Declared In

PFQuery.h

getFirstObject

Gets an object based on the constructed query.

- (PFObject *)getFirstObject

Return Value

Returns a PFObject, or nil if none was found.

Discussion

Gets an object based on the constructed query.

This mutates the PFQuery.

Declared In

PFQuery.h

getFirstObject:

Gets an object based on the constructed query and sets an error if any occurred.

- (PFObject *)getFirstObject:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns a PFObject, or nil if none was found.

Discussion

Gets an object based on the constructed query and sets an error if any occurred.

This mutates the PFQuery.

Declared In

PFQuery.h

getFirstObjectInBackgroundWithBlock:

Gets an object asynchronously and calls the given block with the result.

- (void)getFirstObjectInBackgroundWithBlock:(PFObjectResultBlock)block

Parameters

block

The block to execute. The block should have the following argument signature:(PFObject object, NSError error) result will be nil if error is set OR no object was found matching the query. error will be nil if result is set OR if the query succeeded, but found no results.

Discussion

Gets an object asynchronously and calls the given block with the result.

This mutates the PFQuery.

Declared In

PFQuery.h

getFirstObjectInBackgroundWithTarget:selector:

Gets an object asynchronously and calls the given callback with the results.

- (void)getFirstObjectInBackgroundWithTarget:(id)target selector:(SEL)selector

Parameters

target

The object to call the selector on.

selector

The selector to call. It should have the following signature: (void)callbackWithResult:(PFObject )result error:(NSError )error. result will be nil if error is set OR no object was found matching the query. error will be nil if result is set OR if the query succeeded, but found no results.

Discussion

Gets an object asynchronously and calls the given callback with the results.

This mutates the PFQuery.

Declared In

PFQuery.h

getObjectInBackgroundWithId:block:

Gets a PFObject asynchronously and calls the given block with the result.

- (void)getObjectInBackgroundWithId:(NSString *)objectId block:(PFObjectResultBlock)block

Parameters

block

The block to execute. The block should have the following argument signature: (NSArray object, NSError error)

Discussion

Gets a PFObject asynchronously and calls the given block with the result.

This mutates the PFQuery

Declared In

PFQuery.h

getObjectInBackgroundWithId:target:selector:

Gets a PFObject asynchronously.

- (void)getObjectInBackgroundWithId:(NSString *)objectId target:(id)target selector:(SEL)selector

Parameters

objectId

The id of the object being requested.

target

The target for the callback selector.

selector

The selector for the callback. It should have the following signature: (void)callbackWithResult:(PFObject )result error:(NSError )error. result will be nil if error is set and vice versa.

Discussion

Gets a PFObject asynchronously.

This mutates the PFQuery

Declared In

PFQuery.h

getObjectWithId:

Returns a PFObject with the given id.

- (PFObject *)getObjectWithId:(NSString *)objectId

Parameters

objectId

The id of the object that is being requested.

Return Value

The PFObject if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFObject with the given id.

This mutates the PFQuery.

Declared In

PFQuery.h

getObjectWithId:error:

Returns a PFObject with the given id and sets an error if necessary.

- (PFObject *)getObjectWithId:(NSString *)objectId error:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

The PFObject if found. Returns nil if the object isn’t found, or if there was an error.

Discussion

Returns a PFObject with the given id and sets an error if necessary.

This mutates the PFQuery

Declared In

PFQuery.h

hasCachedResult

Returns whether there is a cached result for this query.

- (BOOL)hasCachedResult

Return Value

YES if there is a cached result for this query, and NO otherwise.

Discussion

Returns whether there is a cached result for this query.

Declared In

PFQuery.h

includeKey:

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.

- (void)includeKey:(NSString *)key

Parameters

key

The key to load child PFObjects for.

Discussion

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.

Declared In

PFQuery.h

initWithClassName:

Initializes the query with a class name.

- (id)initWithClassName:(NSString *)newClassName

Parameters

newClassName

The class name.

Discussion

Initializes the query with a class name.

Declared In

PFQuery.h

orderByAscending:

Sort the results in ascending order with the given key.

- (void)orderByAscending:(NSString *)key

Parameters

key

The key to order by.

Discussion

Sort the results in ascending order with the given key.

Declared In

PFQuery.h

orderByDescending:

Sort the results in descending order with the given key.

- (void)orderByDescending:(NSString *)key

Parameters

key

The key to order by.

Discussion

Sort the results in descending order with the given key.

Declared In

PFQuery.h

orderBySortDescriptor:

Sort the results in descending order with the given descriptor.

- (void)orderBySortDescriptor:(NSSortDescriptor *)sortDescriptor

Parameters

sortDescriptor

The NSSortDescriptor to order by.

Discussion

Sort the results in descending order with the given descriptor.

Declared In

PFQuery.h

orderBySortDescriptors:

Sort the results in descending order with the given descriptors.

- (void)orderBySortDescriptors:(NSArray *)sortDescriptors

Parameters

sortDescriptors

An NSArray of NSSortDescriptor instances to order by.

Discussion

Sort the results in descending order with the given descriptors.

Declared In

PFQuery.h

selectKeys:

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.

- (void)selectKeys:(NSArray *)keys

Parameters

keys

The keys to include in the result.

Discussion

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.

Declared In

PFQuery.h

whereKey:containedIn:

Add a constraint to the query that requires a particular key’s object to be contained in the provided array.

- (void)whereKey:(NSString *)key containedIn:(NSArray *)array

Parameters

key

The key to be constrained.

array

The possible values for the key’s object.

Discussion

Add a constraint to the query that requires a particular key’s object to be contained in the provided array.

Declared In

PFQuery.h

whereKey:containsAllObjectsInArray:

Add a constraint to the query that requires a particular key’s array contains every element of the provided array.

- (void)whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array

Parameters

key

The key to be constrained.

array

The array of values to search for.

Discussion

Add a constraint to the query that requires a particular key’s array contains every element of the provided array.

Declared In

PFQuery.h

whereKey:containsString:

Add a constraint for finding string values that contain a provided substring.
This will be slow for large datasets.

- (void)whereKey:(NSString *)key containsString:(NSString *)substring

Parameters

key

The key that the string to match is stored in.

substring

The substring that the value must contain.

Discussion

Add a constraint for finding string values that contain a provided substring.
This will be slow for large datasets.

Declared In

PFQuery.h

whereKey:doesNotMatchKey:inQuery:

Adds a constraint that requires that a key’s value NOT match a value in another key
in objects returned by a sub query.

- (void)whereKey:(NSString *)key doesNotMatchKey:(NSString *)otherKey inQuery:(PFQuery *)query

Parameters

key

The key that the value is stored

otherKey

The key in objects in the returned by the sub query whose value should match

query

The query to run.

Discussion

Adds a constraint that requires that a key’s value NOT match a value in another key
in objects returned by a sub query.

Declared In

PFQuery.h

whereKey:doesNotMatchQuery:

Add a constraint that requires that a key’s value to not match a PFQuery constraint.
This only works where the key’s values are PFObjects or arrays of PFObjects.

- (void)whereKey:(NSString *)key doesNotMatchQuery:(PFQuery *)query

Parameters

key

The key that the value is stored in

query

The query the value should not match

Discussion

Add a constraint that requires that a key’s value to not match a PFQuery constraint.
This only works where the key’s values are PFObjects or arrays of PFObjects.

Declared In

PFQuery.h

whereKey:equalTo:

Add a constraint to the query that requires a particular key’s object to be equal to the provided object.

- (void)whereKey:(NSString *)key equalTo:(id)object

Parameters

key

The key to be constrained.

object

The object that must be equalled.

Discussion

Add a constraint to the query that requires a particular key’s object to be equal to the provided object.

Declared In

PFQuery.h

whereKey:greaterThan:

Add a constraint to the query that requires a particular key’s object to be greater than the provided object.

- (void)whereKey:(NSString *)key greaterThan:(id)object

Parameters

key

The key to be constrained.

object

The object that must be equalled.

Discussion

Add a constraint to the query that requires a particular key’s object to be greater than the provided object.

Declared In

PFQuery.h

whereKey:greaterThanOrEqualTo:

Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.

- (void)whereKey:(NSString *)key greaterThanOrEqualTo:(id)object

Parameters

key

The key to be constrained.

object

The object that must be equalled.

Discussion

Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.

Declared In

PFQuery.h

whereKey:hasPrefix:

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.

- (void)whereKey:(NSString *)key hasPrefix:(NSString *)prefix

Parameters

key

The key that the string to match is stored in.

prefix

The substring that the value must start with.

Discussion

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.

Declared In

PFQuery.h

whereKey:hasSuffix:

Add a constraint for finding string values that end with a provided suffix.
This will be slow for large datasets.

- (void)whereKey:(NSString *)key hasSuffix:(NSString *)suffix

Parameters

key

The key that the string to match is stored in.

suffix

The substring that the value must end with.

Discussion

Add a constraint for finding string values that end with a provided suffix.
This will be slow for large datasets.

Declared In

PFQuery.h

whereKey:lessThan:

Add a constraint to the query that requires a particular key’s object to be less than the provided object.

- (void)whereKey:(NSString *)key lessThan:(id)object

Parameters

key

The key to be constrained.

object

The object that provides an upper bound.

Discussion

Add a constraint to the query that requires a particular key’s object to be less than the provided object.

Declared In

PFQuery.h

whereKey:lessThanOrEqualTo:

Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.

- (void)whereKey:(NSString *)key lessThanOrEqualTo:(id)object

Parameters

key

The key to be constrained.

object

The object that must be equalled.

Discussion

Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.

Declared In

PFQuery.h

whereKey:matchesKey:inQuery:

Adds a constraint that requires that a key’s value matches a value in another key
in objects returned by a sub query.

- (void)whereKey:(NSString *)key matchesKey:(NSString *)otherKey inQuery:(PFQuery *)query

Parameters

key

The key that the value is stored

otherKey

The key in objects in the returned by the sub query whose value should match

query

The query to run.

Discussion

Adds a constraint that requires that a key’s value matches a value in another key
in objects returned by a sub query.

Declared In

PFQuery.h

whereKey:matchesQuery:

Add a constraint that requires that a key’s value matches a PFQuery constraint.
This only works where the key’s values are PFObjects or arrays of PFObjects.

- (void)whereKey:(NSString *)key matchesQuery:(PFQuery *)query

Parameters

key

The key that the value is stored in

query

The query the value should match

Discussion

Add a constraint that requires that a key’s value matches a PFQuery constraint.
This only works where the key’s values are PFObjects or arrays of PFObjects.

Declared In

PFQuery.h

whereKey:matchesRegex:

Add a regular expression constraint for finding string values that match the provided regular expression.
This may be slow for large datasets.

- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex

Parameters

key

The key that the string to match is stored in.

regex

The regular expression pattern to match.

Discussion

Add a regular expression constraint for finding string values that match the provided regular expression.
This may be slow for large datasets.

Declared In

PFQuery.h

whereKey:matchesRegex:modifiers:

Add a regular expression constraint for finding string values that match the provided regular expression.
This may be slow for large datasets.

- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex modifiers:(NSString *)modifiers

Parameters

key

The key that the string to match is stored in.

regex

The regular expression pattern to match.

modifiers

Any of the following supported PCRE modifiers:
i - Case insensitive search
m - Search across multiple lines of input

Discussion

Add a regular expression constraint for finding string values that match the provided regular expression.
This may be slow for large datasets.

Declared In

PFQuery.h

whereKey:nearGeoPoint:

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.

- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint

Parameters

key

The key to be constrained.

geopoint

The reference point. A PFGeoPoint.

Discussion

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.

Declared In

PFQuery.h

whereKey:nearGeoPoint:withinKilometers:

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.

- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinKilometers:(double)maxDistance

Parameters

key

The key to be constrained.

geopoint

The reference point. A PFGeoPoint.

maxDistance

Maximum distance in kilometers.

Discussion

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.

Declared In

PFQuery.h

whereKey:nearGeoPoint:withinMiles:

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.

- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinMiles:(double)maxDistance

Parameters

key

The key to be constrained.

geopoint

The reference point. A PFGeoPoint.

maxDistance

Maximum distance in miles.

Discussion

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.

Declared In

PFQuery.h

whereKey:nearGeoPoint:withinRadians:

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.

- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinRadians:(double)maxDistance

Parameters

key

The key to be constrained.

geopoint

The reference point. A PFGeoPoint.

maxDistance

Maximum distance in radians.

Discussion

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.

Declared In

PFQuery.h

whereKey:notContainedIn:

Add a constraint to the query that requires a particular key’s object not be contained in the provided array.

- (void)whereKey:(NSString *)key notContainedIn:(NSArray *)array

Parameters

key

The key to be constrained.

array

The list of values the key’s object should not be.

Discussion

Add a constraint to the query that requires a particular key’s object not be contained in the provided array.

Declared In

PFQuery.h

whereKey:notEqualTo:

Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.

- (void)whereKey:(NSString *)key notEqualTo:(id)object

Parameters

key

The key to be constrained.

object

The object that must not be equalled.

Discussion

Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.

Declared In

PFQuery.h

whereKey:withinGeoBoxFromSouthwest:toNortheast:

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.

- (void)whereKey:(NSString *)key withinGeoBoxFromSouthwest:(PFGeoPoint *)southwest toNortheast:(PFGeoPoint *)northeast

Parameters

key

The key to be constrained.

southwest

The lower-left inclusive corner of the box.

northeast

The upper-right inclusive corner of the box.

Discussion

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.

Declared In

PFQuery.h

whereKeyDoesNotExist:

Add a constraint that requires a key not exist.

- (void)whereKeyDoesNotExist:(NSString *)key

Parameters

key

The key that should not exist.

Discussion

Add a constraint that requires a key not exist.

Declared In

PFQuery.h

whereKeyExists:

Add a constraint that requires a particular key exists.

- (void)whereKeyExists:(NSString *)key

Parameters

key

The key that should exist.

Discussion

Add a constraint that requires a particular key exists.

Declared In

PFQuery.h