PFObject Class Reference

Inherits from NSObject
Declared in PFObject.h

Overview

The PFObject class is a local representation of data persisted to the Parse cloud. This is the main class that is used to interact with objects in your app.

Subclassing Notes

Developers can subclass PFObject for a more native object-oriented class structure. Strongly-typed subclasses of PFObject must conform to the PFSubclassing protocol and must call before [Parse setApplicationId:clientKey:] is called. After this it will be returned by PFQuery and other PFObject factories.

All methods in PFSubclassing except for [PFSubclassing parseClassName] are already implemented in the PFObject+Subclass category.

Including PFObject+Subclass.h in your implementation file provides these implementations automatically.

Subclasses support simpler initializers, query syntax, and dynamic synthesizers. The following shows an example subclass:

 \@interface MYGame : PFObject PFSubclassing

 // Accessing this property is the same as objectForKey:@"title"
 @property (nonatomic, copy) NSString *title;

 + (NSString *)parseClassName;

 @end


 @implementation MYGame

 @dynamic title;

 + (NSString *)parseClassName {
     return @"Game";
 }

 @end


 MYGame *game = [[MYGame alloc] init];
 game.title = @"Bughouse";
 [game saveInBackground];

Creating a PFObject

– initWithClassName:

Initializes a new empty PFObject instance with a class name.

- (instancetype)initWithClassName:(NSString *)newClassName

Parameters

newClassName

A class name can be any alphanumeric string that begins with a letter. It represents an object in your app, like a ‘User’ or a ‘Document’.

Return Value

Returns the object that is instantiated with the given class name.

Declared In

PFObject.h

+ objectWithClassName:

Creates a new PFObject with a class name.

+ (instancetype)objectWithClassName:(NSString *)className

Parameters

className

A class name can be any alphanumeric string that begins with a letter. It represents an object in your app, like a ‘User’ or a ‘Document’.

Return Value

Returns the object that is instantiated with the given class name.

Declared In

PFObject.h

+ objectWithClassName:dictionary:

Creates a new PFObject with a class name, initialized with data constructed from the specified set of objects and keys.

+ (instancetype)objectWithClassName:(NSString *)className dictionary:(PF_NULLABLE NSDictionary *)dictionary

Parameters

className

The object’s class.

dictionary

An NSDictionary of keys and objects to set on the new PFObject.

Return Value

A PFObject with the given class name and set with the given data.

Declared In

PFObject.h

+ objectWithoutDataWithClassName:objectId:

Creates a reference to an existing PFObject for use in creating associations between PFObjects.

+ (instancetype)objectWithoutDataWithClassName:(NSString *)className objectId:(PF_NULLABLE NSString *)objectId

Parameters

className

The object’s class.

objectId

The object id for the referenced object.

Return Value

A PFObject instance without data.

Discussion

Calling isDataAvailable on this object will return NO until fetchIfNeeded has been called. No network request will be made.

Declared In

PFObject.h

Managing Object Properties

  parseClassName

The class name of the object.

@property (strong, readonly) NSString *parseClassName

Declared In

PFObject.h

  objectId

The id of the object.

@property (PF_NULLABLE_PROPERTY, nonatomic, strong) NSString *objectId

Declared In

PFObject.h

  updatedAt

When the object was last updated.

@property (PF_NULLABLE_PROPERTY, nonatomic, strong, readonly) NSDate *updatedAt

Declared In

PFObject.h

  createdAt

When the object was created.

@property (PF_NULLABLE_PROPERTY, nonatomic, strong, readonly) NSDate *createdAt

Declared In

PFObject.h

  ACL

The ACL for this object.

@property (PF_NULLABLE_PROPERTY, nonatomic, strong) PFACL *ACL

Declared In

PFObject.h

– allKeys

Returns an array of the keys contained in this object.

- (NSArray *)allKeys

Discussion

This does not include createdAt, updatedAt, authData, or objectId. It does include things like username and ACL.

Declared In

PFObject.h

Accessors

– objectForKey:

Returns the value associated with a given key.

- (PF_NULLABLE_S id)objectForKey:(NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

PFObject.h

– setObject:forKey:

Sets the object associated with a given key.

- (void)setObject:(id)object forKey:(NSString *)key

Parameters

object

The object for key. A strong reference to the object is maintained by PFObject. Raises an NSInvalidArgumentException if object is nil. If you need to represent a nil value - use NSNull.

key

The key for object. Raises an NSInvalidArgumentException if key is nil.

Declared In

PFObject.h

– removeObjectForKey:

Unsets a key on the object.

- (void)removeObjectForKey:(NSString *)key

Parameters

key

The key.

Declared In

PFObject.h

– objectForKeyedSubscript:

Returns the value associated with a given key.

- (PF_NULLABLE_S id)objectForKeyedSubscript:(NSString *)key

Parameters

key

The key for which to return the corresponding value.

Discussion

This method enables usage of literal syntax on PFObject. E.g. NSString *value = object[@"key"];

See Also

Declared In

PFObject.h

– setObject:forKeyedSubscript:

Returns the value associated with a given key.

- (void)setObject:(PF_NULLABLE_S id)object forKeyedSubscript:(NSString *)key

Parameters

object

The object for key. A strong reference to the object is maintained by PFObject. Raises an NSInvalidArgumentException if object is nil. If you need to represent a nil value - use NSNull.

key

The key for object. Raises an NSInvalidArgumentException if key is nil.

Discussion

This method enables usage of literal syntax on PFObject. E.g. object[@"key"] = @"value";

Declared In

PFObject.h

– relationForKey:

Returns the relation object associated with the given key.

- (PFRelation *)relationForKey:(NSString *)key

Parameters

key

The key that the relation is associated with.

Declared In

PFObject.h

– relationforKey:

Returns the relation object associated with the given key. (Deprecated: Please use [PFObject relationForKey:] instead.)

- (PFRelation *)relationforKey:(NSString *)key

Parameters

key

The key that the relation is associated with.

Declared In

PFObject.h

– revert

Clears any changes to this object made since the last call to save and sets it back to the server state.

- (void)revert

Declared In

PFObject.h

– revertObjectForKey:

Clears any changes to this object’s key that were done after last successful save and sets it back to the server state.

- (void)revertObjectForKey:(NSString *)key

Parameters

key

The key to revert changes for.

Declared In

PFObject.h

Array Accessors

– addObject:forKey:

Adds an object to the end of the array associated with a given key.

- (void)addObject:(id)object forKey:(NSString *)key

Parameters

object

The object to add.

key

The key.

Declared In

PFObject.h

– addObjectsFromArray:forKey:

Adds the objects contained in another array to the end of the array associated with a given key.

- (void)addObjectsFromArray:(NSArray *)objects forKey:(NSString *)key

Parameters

objects

The array of objects to add.

key

The key.

Declared In

PFObject.h

– addUniqueObject:forKey:

Adds an object to the array associated with a given key, only if it is not already present in the array.

- (void)addUniqueObject:(id)object forKey:(NSString *)key

Parameters

object

The object to add.

key

The key.

Discussion

The position of the insert is not guaranteed.

Declared In

PFObject.h

– addUniqueObjectsFromArray:forKey:

Adds the objects contained in another array to the array associated with a given key, only adding elements which are not already present in the array.

@dicsussion The position of the insert is not guaranteed.

- (void)addUniqueObjectsFromArray:(NSArray *)objects forKey:(NSString *)key

Parameters

objects

The array of objects to add.

key

The key.

Declared In

PFObject.h

– removeObject:forKey:

Removes all occurrences of an object from the array associated with a given key.

- (void)removeObject:(id)object forKey:(NSString *)key

Parameters

object

The object to remove.

key

The key.

Declared In

PFObject.h

– removeObjectsInArray:forKey:

Removes all occurrences of the objects contained in another array from the array associated with a given key.

- (void)removeObjectsInArray:(NSArray *)objects forKey:(NSString *)key

Parameters

objects

The array of objects to remove.

key

The key.

Declared In

PFObject.h

Increment

– incrementKey:

Increments the given key by 1.

- (void)incrementKey:(NSString *)key

Parameters

key

The key.

Declared In

PFObject.h

– incrementKey:byAmount:

Increments the given key by a number.

- (void)incrementKey:(NSString *)key byAmount:(NSNumber *)amount

Parameters

key

The key.

amount

The amount to increment.

Declared In

PFObject.h

Saving Objects

– save

Synchronously saves the PFObject.

- (BOOL)save

Return Value

Returns whether the save succeeded.

Declared In

PFObject.h

– save:

Synchronously saves the PFObject and sets an error if it occurs.

- (BOOL)save:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the save succeeded.

Declared In

PFObject.h

– saveInBackground

Saves the PFObject asynchronously.

- (BFTask *)saveInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– saveInBackgroundWithBlock:

Saves the PFObject asynchronously and executes the given callback block.

- (void)saveInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

– saveEventually

Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.

- (BFTask *)saveEventually

Return Value

The task that encapsulates the work being done.

Discussion

Use this when you may not have a solid network connection, and don’t need to know when the save completes. If there is some problem with the object such that it can’t be saved, it will be silently discarded. If the save completes successfully while the object is still in memory, then callback will be called.

Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Objects saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to will cause old saves to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Declared In

PFObject.h

– saveEventually:

Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.

- (void)saveEventually:(PF_NULLABLE PFBooleanResultBlock)callback

Parameters

callback

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Discussion

Use this when you may not have a solid network connection, and don’t need to know when the save completes. If there is some problem with the object such that it can’t be saved, it will be silently discarded. If the save completes successfully while the object is still in memory, then callback will be called.

Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Objects saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to saveEventually will cause old saves to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Declared In

PFObject.h

Saving Many Objects

+ saveAll:

Saves a collection of objects *synchronously all at once.

+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects

Parameters

objects

The array of objects to save.

Return Value

Returns whether the save succeeded.

Declared In

PFObject.h

+ saveAll:error:

Saves a collection of objects synchronously all at once and sets an error if necessary.

+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The array of objects to save.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the save succeeded.

Declared In

PFObject.h

+ saveAllInBackground:

Saves a collection of objects all at once asynchronously.

+ (BFTask *)saveAllInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The array of objects to save.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ saveAllInBackground:block:

Saves a collection of objects all at once asynchronously and executes the block when done.

+ (void)saveAllInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The array of objects to save.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

Deleting Many Objects

+ deleteAll:

Synchronously deletes a collection of objects all at once.

+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects

Parameters

objects

The array of objects to delete.

Return Value

Returns whether the delete succeeded.

Declared In

PFObject.h

+ deleteAll:error:

Synchronously deletes a collection of objects all at once and sets an error if necessary.

+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The array of objects to delete.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the delete succeeded.

Declared In

PFObject.h

+ deleteAllInBackground:

Deletes a collection of objects all at once asynchronously.

+ (BFTask *)deleteAllInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The array of objects to delete.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ deleteAllInBackground:block:

Deletes a collection of objects all at once asynchronously and executes the block when done.

+ (void)deleteAllInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The array of objects to delete.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

Getting an Object

– isDataAvailable

Gets whether the PFObject has been fetched.

- (BOOL)isDataAvailable

Return Value

YES if the PFObject is new or has been fetched or refreshed, otherwise NO.

Declared In

PFObject.h

– refresh

Refreshes the PFObject with the current data from the server. (Deprecated: Please use -fetch instead.)

- (void)refresh

Declared In

PFObject.h

– refresh:

Synchronously refreshes the PFObject with the current data from the server and sets an error if it occurs. (Deprecated: Please use -fetch: instead.)

- (void)refresh:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Declared In

PFObject.h

– refreshInBackgroundWithBlock:

Asynchronously refreshes the PFObject and executes the given callback block. (Deprecated: Please use -fetchInBackgroundWithBlock: instead.)

- (void)refreshInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block

Parameters

block

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

Declared In

PFObject.h

– fetch

Synchronously fetches the PFObject with the current data from the server.

- (void)fetch

Declared In

PFObject.h

– fetch:

Synchronously fetches the PFObject with the current data from the server and sets an error if it occurs.

- (void)fetch:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Declared In

PFObject.h

– fetchIfNeeded

Synchronously fetches the PFObject data from the server if isDataAvailable is NO.

- (PF_NULLABLE PFObject *)fetchIfNeeded

Declared In

PFObject.h

– fetchIfNeeded:

Synchronously fetches the PFObject data from the server if isDataAvailable is NO.

- (PF_NULLABLE PFObject *)fetchIfNeeded:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Declared In

PFObject.h

– fetchInBackground

Fetches the PFObject asynchronously and sets it as a result for the task.

- (BFTask *)fetchInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– fetchInBackgroundWithBlock:

Fetches the PFObject asynchronously and executes the given callback block.

- (void)fetchInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(PFObject *object, NSError *error).

Declared In

PFObject.h

– fetchIfNeededInBackground

Fetches the PFObject data asynchronously if isDataAvailable is NO, then sets it as a result for the task.

- (BFTask *)fetchIfNeededInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– fetchIfNeededInBackgroundWithBlock:

Fetches the PFObject data asynchronously if isDataAvailable is NO, then calls the callback block.

- (void)fetchIfNeededInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(PFObject *object, NSError *error).

Declared In

PFObject.h

Getting Many Objects

+ fetchAll:

Synchronously fetches all of the PFObject objects with the current data from the server.

+ (void)fetchAll:(PF_NULLABLE NSArray *)objects

Parameters

objects

The list of objects to fetch.

Declared In

PFObject.h

+ fetchAll:error:

Synchronously fetches all of the PFObject objects with the current data from the server and sets an error if it occurs.

+ (void)fetchAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The list of objects to fetch.

error

Pointer to an NSError that will be set if necessary.

Declared In

PFObject.h

+ fetchAllIfNeeded:

Synchronously fetches all of the PFObject objects with the current data from the server.

+ (void)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects

Parameters

objects

The list of objects to fetch.

Declared In

PFObject.h

+ fetchAllIfNeeded:error:

Synchronously fetches all of the PFObject objects with the current data from the server and sets an error if it occurs.

+ (void)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The list of objects to fetch.

error

Pointer to an NSError that will be set if necessary.

Declared In

PFObject.h

+ fetchAllInBackground:

Fetches all of the PFObject objects with the current data from the server asynchronously.

+ (BFTask *)fetchAllInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The list of objects to fetch.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ fetchAllInBackground:block:

Fetches all of the PFObject objects with the current data from the server asynchronously and calls the given block.

+ (void)fetchAllInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFArrayResultBlock)block

Parameters

objects

The list of objects to fetch.

block

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

Declared In

PFObject.h

+ fetchAllIfNeededInBackground:

Fetches all of the PFObject objects with the current data from the server asynchronously.

+ (BFTask *)fetchAllIfNeededInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The list of objects to fetch.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ fetchAllIfNeededInBackground:block:

Fetches all of the PFObjects with the current data from the server asynchronously and calls the given block.

+ (void)fetchAllIfNeededInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFArrayResultBlock)block

Parameters

objects

The list of objects to fetch.

block

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

Declared In

PFObject.h

Fetching From Local Datastore

– fetchFromLocalDatastore

Synchronously loads data from the local datastore into this object, if it has not been fetched from the server already.

- (void)fetchFromLocalDatastore

Declared In

PFObject.h

– fetchFromLocalDatastore:

Synchronously loads data from the local datastore into this object, if it has not been fetched from the server already.

- (void)fetchFromLocalDatastore:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Discussion

If the object is not stored in the local datastore, this error will be set to return kPFErrorCacheMiss.

Declared In

PFObject.h

– fetchFromLocalDatastoreInBackground

Asynchronously loads data from the local datastore into this object, if it has not been fetched from the server already.

- (BFTask *)fetchFromLocalDatastoreInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– fetchFromLocalDatastoreInBackgroundWithBlock:

Asynchronously loads data from the local datastore into this object, if it has not been fetched from the server already.

- (void)fetchFromLocalDatastoreInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(PFObject *object, NSError *error).

Declared In

PFObject.h

Deleting an Object

– delete

Synchronously deletes the PFObject.

- (BOOL)delete

Return Value

Returns whether the delete succeeded.

Declared In

PFObject.h

– delete:

Synchronously deletes the PFObject and sets an error if it occurs.

- (BOOL)delete:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the delete succeeded.

Declared In

PFObject.h

– deleteInBackground

Deletes the PFObject asynchronously.

- (BFTask *)deleteInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– deleteInBackgroundWithBlock:

Deletes the PFObject asynchronously and executes the given callback block.

- (void)deleteInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

– deleteEventually

Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.

- (BFTask *)deleteEventually

Return Value

The task that encapsulates the work being done.

Discussion

Use this when you may not have a solid network connection, and don’t need to know when the delete completes. If there is some problem with the object such that it can’t be deleted, the request will be silently discarded.

Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Delete requests will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of saveEventually or commands are waiting to be sent, subsequent calls to saveEventually or will cause old requests to be silently discarded until the connection can be re-established, and the queued requests can go through.

Declared In

PFObject.h

Dirtiness

– isDirty

Gets whether any key-value pair in this object (or its children) has been added/updated/removed and not saved yet.

- (BOOL)isDirty

Return Value

Returns whether this object has been altered and not saved yet.

Declared In

PFObject.h

– isDirtyForKey:

Get whether a value associated with a key has been added/updated/removed and not saved yet.

- (BOOL)isDirtyForKey:(NSString *)key

Parameters

key

The key to check for

Return Value

Returns whether this key has been altered and not saved yet.

Declared In

PFObject.h

Pinning

– pin

Synchronously stores the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BOOL)pin

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

See Also

Declared In

PFObject.h

– pin:

Synchronously stores the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BOOL)pin:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

See Also

Declared In

PFObject.h

– pinWithName:

Synchronously stores the object and every object it points to in the local datastore, recursively.

- (BOOL)pinWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

See Also

Declared In

PFObject.h

– pinWithName:error:

Synchronously stores the object and every object it points to in the local datastore, recursively.

- (BOOL)pinWithName:(NSString *)name error:(NSError **)error

Parameters

name

The name of the pin.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

See Also

Declared In

PFObject.h

– pinInBackground

Asynchronously stores the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BFTask *)pinInBackground

Return Value

The task that encapsulates the work being done.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

Declared In

PFObject.h

– pinInBackgroundWithBlock:

Asynchronously stores the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (void)pinInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

Declared In

PFObject.h

– pinInBackgroundWithName:

Asynchronously stores the object and every object it points to in the local datastore, recursively.

- (BFTask *)pinInBackgroundWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

The task that encapsulates the work being done.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

Declared In

PFObject.h

– pinInBackgroundWithName:block:

Asynchronously stores the object and every object it points to in the local datastore, recursively.

- (void)pinInBackgroundWithName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

name

The name of the pin.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore on it.

Declared In

PFObject.h

Pinning Many Objects

+ pinAll:

Synchronously stores the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects

Parameters

objects

The objects to be pinned.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

See Also

Declared In

PFObject.h

+ pinAll:error:

Synchronously stores the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The objects to be pinned.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAll:withName:

Synchronously stores the objects and every object they point to in the local datastore, recursively.

+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name

Parameters

objects

The objects to be pinned.

name

The name of the pin.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAll:withName:error:

Synchronously stores the objects and every object they point to in the local datastore, recursively.

+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name error:(NSError **)error

Parameters

objects

The objects to be pinned.

name

The name of the pin.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the pin succeeded.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAllInBackground:

Asynchronously stores the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BFTask *)pinAllInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The objects to be pinned.

Return Value

The task that encapsulates the work being done.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAllInBackground:block:

Asynchronously stores the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (void)pinAllInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The objects to be pinned.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAllInBackground:withName:

Asynchronously stores the objects and every object they point to in the local datastore, recursively.

+ (BFTask *)pinAllInBackground:(PF_NULLABLE NSArray *)objects withName:(NSString *)name

Parameters

objects

The objects to be pinned.

name

The name of the pin.

Return Value

The task that encapsulates the work being done.

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

+ pinAllInBackground:withName:block:

Asynchronously stores the objects and every object they point to in the local datastore, recursively.

+ (void)pinAllInBackground:(PF_NULLABLE NSArray *)objects withName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The objects to be pinned.

name

The name of the pin.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Discussion

If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all the changes will be retained. To get the objects back later, you can use a PFQuery that uses [PFQuery fromLocalDatastore], or you can create an unfetched pointer with [PFObject objectWithoutDataWithClassName:objectId:] and then call fetchFromLocalDatastore: on it.

Declared In

PFObject.h

Unpinning

– unpin

Synchronously removes the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BOOL)unpin

Return Value

Returns whether the unpin succeeded.

See Also

Declared In

PFObject.h

– unpin:

Synchronously removes the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BOOL)unpin:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

See Also

Declared In

PFObject.h

– unpinWithName:

Synchronously removes the object and every object it points to in the local datastore, recursively.

- (BOOL)unpinWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

Returns whether the unpin succeeded.

See Also

Declared In

PFObject.h

– unpinWithName:error:

Synchronously removes the object and every object it points to in the local datastore, recursively.

- (BOOL)unpinWithName:(NSString *)name error:(NSError **)error

Parameters

name

The name of the pin.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

– unpinInBackground

Asynchronously removes the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (BFTask *)unpinInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– unpinInBackgroundWithBlock:

Asynchronously removes the object and every object it points to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

- (void)unpinInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

– unpinInBackgroundWithName:

Asynchronously removes the object and every object it points to in the local datastore, recursively.

- (BFTask *)unpinInBackgroundWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

– unpinInBackgroundWithName:block:

Asynchronously removes the object and every object it points to in the local datastore, recursively.

- (void)unpinInBackgroundWithName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

name

The name of the pin.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

Unpinning Many Objects

+ unpinAllObjects

Synchronously removes all objects in the local datastore using a default pin name: PFObjectDefaultPin.

+ (BOOL)unpinAllObjects

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAllObjects:

Synchronously removes all objects in the local datastore using a default pin name: PFObjectDefaultPin.

+ (BOOL)unpinAllObjects:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAllObjectsWithName:

Synchronously removes all objects with the specified pin name.

+ (BOOL)unpinAllObjectsWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAllObjectsWithName:error:

Synchronously removes all objects with the specified pin name.

+ (BOOL)unpinAllObjectsWithName:(NSString *)name error:(NSError **)error

Parameters

name

The name of the pin.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAllObjectsInBackground

Asynchronously removes all objects in the local datastore using a default pin name: PFObjectDefaultPin.

+ (BFTask *)unpinAllObjectsInBackground

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ unpinAllObjectsInBackgroundWithBlock:

Asynchronously removes all objects in the local datastore using a default pin name: PFObjectDefaultPin.

+ (void)unpinAllObjectsInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

+ unpinAllObjectsInBackgroundWithName:

Asynchronously removes all objects with the specified pin name.

+ (BFTask *)unpinAllObjectsInBackgroundWithName:(NSString *)name

Parameters

name

The name of the pin.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ unpinAllObjectsInBackgroundWithName:block:

Asynchronously removes all objects with the specified pin name.

+ (void)unpinAllObjectsInBackgroundWithName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

name

The name of the pin.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

+ unpinAll:

Synchronously removes the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects

Parameters

objects

The objects.

Return Value

Returns whether the unpin succeeded.

See Also

Declared In

PFObject.h

+ unpinAll:error:

Synchronously removes the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error

Parameters

objects

The objects.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

See Also

Declared In

PFObject.h

+ unpinAll:withName:

Synchronously removes the objects and every object they point to in the local datastore, recursively.

+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name

Parameters

objects

The objects.

name

The name of the pin.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAll:withName:error:

Synchronously removes the objects and every object they point to in the local datastore, recursively.

+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name error:(NSError **)error

Parameters

objects

The objects.

name

The name of the pin.

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the unpin succeeded.

Declared In

PFObject.h

+ unpinAllInBackground:

Asynchronously removes the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (BFTask *)unpinAllInBackground:(PF_NULLABLE NSArray *)objects

Parameters

objects

The objects.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ unpinAllInBackground:block:

Asynchronously removes the objects and every object they point to in the local datastore, recursively, using a default pin name: PFObjectDefaultPin.

+ (void)unpinAllInBackground:(PF_NULLABLE NSArray *)objects block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The objects.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

+ unpinAllInBackground:withName:

Asynchronously removes the objects and every object they point to in the local datastore, recursively.

+ (BFTask *)unpinAllInBackground:(PF_NULLABLE NSArray *)objects withName:(NSString *)name

Parameters

objects

The objects.

name

The name of the pin.

Return Value

The task that encapsulates the work being done.

Declared In

PFObject.h

+ unpinAllInBackground:withName:block:

Asynchronously removes the objects and every object they point to in the local datastore, recursively.

+ (void)unpinAllInBackground:(PF_NULLABLE NSArray *)objects withName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block

Parameters

objects

The objects.

name

The name of the pin.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFObject.h

Subclass Methods

+ object

Creates an instance of the registered subclass with this class’s parseClassName.

+ (instancetype)object

Discussion

This helps a subclass ensure that it can be subclassed itself. For example, [PFUser object] will return a MyUser object if MyUser is a registered subclass of PFUser. For this reason, [MyClass object] is preferred to [[MyClass alloc] init]. This method can only be called on subclasses which conform to PFSubclassing. A default implementation is provided by PFObject which should always be sufficient.

Declared In

PFObject+Subclass.h

+ objectWithoutDataWithObjectId:

Creates a reference to an existing PFObject for use in creating associations between PFObjects.

+ (instancetype)objectWithoutDataWithObjectId:(PF_NULLABLE NSString *)objectId

Parameters

objectId

The object id for the referenced object.

Return Value

An instance of PFObject without data.

Discussion

Calling isDataAvailable on this object will return NO until fetchIfNeeded or fetch has been called. This method can only be called on subclasses which conform to PFSubclassing. A default implementation is provided by PFObject which should always be sufficient. No network request will be made.

Declared In

PFObject+Subclass.h

+ registerSubclass

Registers an Objective-C class for Parse to use for representing a given Parse class.

+ (void)registerSubclass

Discussion

Once this is called on a PFObject subclass, any PFObject Parse creates with a class name that matches [self parseClassName] will be an instance of subclass. This method can only be called on subclasses which conform to PFSubclassing. A default implementation is provided by PFObject which should always be sufficient.

Declared In

PFObject+Subclass.h

+ query

Returns a query for objects of type parseClassName.

+ (PF_NULLABLE PFQuery *)query

Discussion

This method can only be called on subclasses which conform to PFSubclassing. A default implementation is provided by which should always be sufficient.

Declared In

PFObject+Subclass.h

+ queryWithPredicate:

Returns a query for objects of type parseClassName with a given predicate.

+ (PF_NULLABLE PFQuery *)queryWithPredicate:(PF_NULLABLE NSPredicate *)predicate

Parameters

predicate

The predicate to create conditions from.

Return Value

An instance of PFQuery.

Discussion

A default implementation is provided by which should always be sufficient.

Warning: This method can only be called on subclasses which conform to PFSubclassing.

Declared In

PFObject+Subclass.h