Skip to content

Updated nullability annotations and return types for synchronous methods on PFObject. #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions Parse/PFObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS

@see setObject:forKey:
*/
- (void)setObject:(PF_NULLABLE_S id)object forKeyedSubscript:(NSString *)key;
- (void)setObject:(id)object forKeyedSubscript:(NSString *)key;

/*!
@abstract Returns the relation object associated with the given key.
Expand Down Expand Up @@ -504,7 +504,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS

@deprecated Please use `-fetch` instead.
*/
- (instancetype)refresh PF_SWIFT_UNAVAILABLE PARSE_DEPRECATED("Please use `-fetch` instead.");
- (PF_NULLABLE instancetype)refresh PF_SWIFT_UNAVAILABLE PARSE_DEPRECATED("Please use `-fetch` instead.");

/*!
@abstract *Synchronously* refreshes the `PFObject` with the current data from the server and sets an error if it occurs.
Expand All @@ -513,7 +513,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS

@deprecated Please use `-fetch:` instead.
*/
- (instancetype)refresh:(NSError **)error PARSE_DEPRECATED("Please use `-fetch:` instead.");
- (PF_NULLABLE instancetype)refresh:(NSError **)error PARSE_DEPRECATED("Please use `-fetch:` instead.");

/*!
@abstract *Asynchronously* refreshes the `PFObject` and executes the given callback block.
Expand Down Expand Up @@ -544,25 +544,25 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
/*!
@abstract *Synchronously* fetches the PFObject with the current data from the server.
*/
- (instancetype)fetch PF_SWIFT_UNAVAILABLE;
- (PF_NULLABLE instancetype)fetch PF_SWIFT_UNAVAILABLE;
/*!
@abstract *Synchronously* fetches the PFObject with the current data from the server and sets an error if it occurs.

@param error Pointer to an `NSError` that will be set if necessary.
*/
- (instancetype)fetch:(NSError **)error;
- (PF_NULLABLE instancetype)fetch:(NSError **)error;

/*!
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.
*/
- (PF_NULLABLE PFObject *)fetchIfNeeded PF_SWIFT_UNAVAILABLE;
- (PF_NULLABLE instancetype)fetchIfNeeded PF_SWIFT_UNAVAILABLE;

/*!
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.

@param error Pointer to an `NSError` that will be set if necessary.
*/
- (PF_NULLABLE PFObject *)fetchIfNeeded:(NSError **)error;
- (PF_NULLABLE instancetype)fetchIfNeeded:(NSError **)error;

/*!
@abstract Fetches the `PFObject` *asynchronously* and sets it as a result for the task.
Expand Down Expand Up @@ -615,8 +615,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
`error` will be `nil` on success and set if there was an error.
`refreshedObject` will be the `PFObject` with the refreshed data.
*/
- (void)fetchIfNeededInBackgroundWithTarget:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
- (void)fetchIfNeededInBackgroundWithTarget:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector;

///--------------------------------------
/// @name Getting Many Objects
Expand All @@ -627,7 +626,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS

@param objects The list of objects to fetch.
*/
+ (NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
+ (PF_NULLABLE NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;

/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
Expand All @@ -636,13 +635,13 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
@param objects The list of objects to fetch.
@param error Pointer to an `NSError` that will be set if necessary.
*/
+ (NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
+ (PF_NULLABLE NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error;

/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server.
@param objects The list of objects to fetch.
*/
+ (NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
+ (PF_NULLABLE NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;

/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
Expand All @@ -651,7 +650,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
@param objects The list of objects to fetch.
@param error Pointer to an `NSError` that will be set if necessary.
*/
+ (NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
+ (PF_NULLABLE NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects error:(NSError **)error;

/*!
@abstract Fetches all of the `PFObject` objects with the current data from the server *asynchronously*.
Expand Down Expand Up @@ -731,7 +730,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
@abstract *Synchronously* loads data from the local datastore into this object,
if it has not been fetched from the server already.
*/
- (instancetype)fetchFromLocalDatastore PF_SWIFT_UNAVAILABLE;
- (PF_NULLABLE instancetype)fetchFromLocalDatastore PF_SWIFT_UNAVAILABLE;

/*!
@abstract *Synchronously* loads data from the local datastore into this object, if it has not been fetched
Expand All @@ -742,7 +741,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS

@param error Pointer to an `NSError` that will be set if necessary.
*/
- (instancetype)fetchFromLocalDatastore:(NSError **)error;
- (PF_NULLABLE instancetype)fetchFromLocalDatastore:(NSError **)error;

/*!
@abstract *Asynchronously* loads data from the local datastore into this object,
Expand Down
8 changes: 4 additions & 4 deletions Parse/PFObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -2069,11 +2069,11 @@ - (void)fetchInBackgroundWithTarget:(id)target selector:(SEL)selector {
}];
}

- (PFObject *)fetchIfNeeded {
- (instancetype)fetchIfNeeded {
return [self fetchIfNeeded:nil];
}

- (PFObject *)fetchIfNeeded:(NSError **)error {
- (instancetype)fetchIfNeeded:(NSError **)error {
return [[self fetchIfNeededInBackground] waitForResult:error];
}

Expand All @@ -2099,11 +2099,11 @@ - (void)fetchIfNeededInBackgroundWithTarget:(id)target selector:(SEL)selector {
///--------------------------------------

+ (NSArray *)fetchAll:(NSArray *)objects {
return [PFObject fetchAll:objects error:nil];
return [self fetchAll:objects error:nil];
}

+ (NSArray *)fetchAllIfNeeded:(NSArray *)objects {
return [PFObject fetchAllIfNeeded:objects error:nil];
return [self fetchAllIfNeeded:objects error:nil];
}

+ (NSArray *)fetchAll:(NSArray *)objects error:(NSError **)error {
Expand Down
2 changes: 1 addition & 1 deletion Parse/PFUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);

@returns Returns a new `PFUser` object.
*/
+ (PFUser *)user;
+ (instancetype)user;

/*!
@abstract Enables automatic creation of anonymous users.
Expand Down