diff --git a/ParseUI/Classes/LogInViewController/PFLogInViewController.h b/ParseUI/Classes/LogInViewController/PFLogInViewController.h index e952f8d..0c63fcb 100644 --- a/ParseUI/Classes/LogInViewController/PFLogInViewController.h +++ b/ParseUI/Classes/LogInViewController/PFLogInViewController.h @@ -21,6 +21,8 @@ #import +#import + #import #import @@ -70,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN If unspecified, the default is basic facebook permissions. */ -@property (nullable, nonatomic, copy) NSArray *facebookPermissions; +@property (nullable, nonatomic, copy) NSArray PF_GENERIC(NSString *)*facebookPermissions; /** The sign up controller if sign up is enabled. @@ -161,8 +163,7 @@ shouldBeginLogInWithUsername:(NSString *)username @param logInController The login view controller where login failed. @param error `NSError` object representing the error that occured. */ -- (void)logInViewController:(PFLogInViewController *)logInController - didFailToLogInWithError:(nullable NSError *)error; +- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(nullable NSError *)error; /** Sent to the delegate when the log in screen is cancelled. diff --git a/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.h b/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.h index e7ac8aa..1c0b73a 100644 --- a/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.h +++ b/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.h @@ -21,11 +21,12 @@ #import +#import #import NS_ASSUME_NONNULL_BEGIN -@class BFTask; +@class BFTask PF_GENERIC(__covariant BFGenericType); @class PFCollectionViewCell; @class PFObject; @class PFQuery; @@ -126,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN /** The array of instances of `PFObject` that is used as a data source. */ -@property (nonatomic, copy, readonly) NSArray *objects; +@property (nonatomic, copy, readonly) NSArray PF_GENERIC(__kindof PFObject *)*objects; /** Returns an object at a particular indexPath. @@ -148,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN /** Removes all objects at the specified index paths, animated. */ -- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes; +- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexes; ///-------------------------------------- /// @name Loading Data @@ -159,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN @return An awaitable task that completes when the reload succeeds */ -- (BFTask *)loadObjects; +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects; /** Loads the objects of the `PFObject.parseClassName` at the specified page and appends it to the @@ -170,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN @return An awaitable task that completes when the reload succeeds */ -- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear; +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear; /** Loads the next page of objects, appends to table, and refreshes. @@ -209,8 +210,8 @@ NS_ASSUME_NONNULL_BEGIN @return The cell that represents this object. */ - (nullable PFCollectionViewCell *)collectionView:(UICollectionView *)collectionView - cellForItemAtIndexPath:(NSIndexPath *)indexPath - object:(nullable PFObject *)object; + cellForItemAtIndexPath:(NSIndexPath *)indexPath + object:(nullable PFObject *)object; /** Override this method to customize the view that allows the user to load the diff --git a/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.m b/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.m index 2ca9442..429887b 100644 --- a/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.m +++ b/ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.m @@ -36,7 +36,7 @@ static NSString *const PFQueryCollectionViewNextPageReusableViewIdentifier = @"nextPageView"; @interface PFQueryCollectionViewController () { - NSMutableArray *_mutableObjects; + NSMutableArray PF_GENERIC(PFObject *)*_mutableObjects; BOOL _firstLoad; // Whether we have loaded the first set of objects NSInteger _currentPage; // The last page that was loaded @@ -226,11 +226,11 @@ - (void)removeObjectsAtIndexPaths:(NSArray *)indexPaths { #pragma mark - #pragma mark Loading Data -- (BFTask *)loadObjects { +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects { return [self loadObjects:0 clear:YES]; } -- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear { +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear { self.loading = YES; [self objectsWillLoad]; diff --git a/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.h b/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.h index e8b3e0d..917b102 100644 --- a/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.h +++ b/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.h @@ -21,11 +21,12 @@ #import +#import #import NS_ASSUME_NONNULL_BEGIN -@class BFTask; +@class BFTask PF_GENERIC(__covariant BFGenericType); @class PFObject; @class PFQuery; @class PFTableViewCell; @@ -148,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN /** The array of instances of `PFObject` that is used as a data source. */ -@property (nullable, nonatomic, copy, readonly) NSArray *objects; +@property (nullable, nonatomic, copy, readonly) NSArray PF_GENERIC(__kindof PFObject *)*objects; /** Returns an object at a particular indexPath. @@ -175,12 +176,12 @@ NS_ASSUME_NONNULL_BEGIN /** Removes all objects at the specified index paths, animated. */ -- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes; +- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexPaths; /** Removes all objects at the specified index paths, with or without animation. */ -- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes animated:(BOOL)animated; +- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexPaths animated:(BOOL)animated; /** Clears the table of all objects. @@ -192,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN @return An awaitable task that completes when the reload succeeds */ -- (BFTask *)loadObjects; +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *> *)*)loadObjects; /** Loads the objects of the className at the specified page and appends it to the @@ -203,7 +204,7 @@ NS_ASSUME_NONNULL_BEGIN @return An awaitable task that completes when the reload succeeds */ -- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear; +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *> *)*)loadObjects:(NSInteger)page clear:(BOOL)clear; /** Loads the next page of objects, appends to table, and refreshes. @@ -239,8 +240,8 @@ NS_ASSUME_NONNULL_BEGIN @return The cell that represents this object. */ - (nullable PFTableViewCell *)tableView:(UITableView *)tableView - cellForRowAtIndexPath:(NSIndexPath *)indexPath - object:(nullable PFObject *)object; + cellForRowAtIndexPath:(NSIndexPath *)indexPath + object:(nullable PFObject *)object; /** Override this method to customize the cell that allows the user to load the @@ -251,8 +252,7 @@ NS_ASSUME_NONNULL_BEGIN @return The cell that allows the user to paginate. */ -- (nullable PFTableViewCell *)tableView:(UITableView *)tableView - cellForNextPageAtIndexPath:(NSIndexPath *)indexPath; +- (nullable PFTableViewCell *)tableView:(UITableView *)tableView cellForNextPageAtIndexPath:(NSIndexPath *)indexPath; @end diff --git a/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.m b/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.m index bfb5d83..d07a461 100644 --- a/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.m +++ b/ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.m @@ -45,7 +45,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB @end @interface PFQueryTableViewController () { - NSMutableArray *_mutableObjects; + NSMutableArray PF_GENERIC(PFObject *)*_mutableObjects; BOOL _firstLoad; // Whether we have loaded the first set of objects NSInteger _currentPage; // The last page that was loaded @@ -212,11 +212,11 @@ - (void)clear { _currentPage = 0; } -- (BFTask *)loadObjects { +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects { return [self loadObjects:0 clear:YES]; } -- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear { +- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear { self.loading = YES; [self objectsWillLoad]; @@ -554,7 +554,7 @@ - (void)_refreshControlValueChanged:(UIRefreshControl *)refreshControl { #pragma mark - #pragma mark Accessors -- (NSArray *)objects { +- (NSArray PF_GENERIC(__kindof PFObject *)*)objects { return _mutableObjects; } diff --git a/ParseUI/Classes/SignUpViewController/PFSignUpViewController.h b/ParseUI/Classes/SignUpViewController/PFSignUpViewController.h index 2d9c7e9..e9baf62 100644 --- a/ParseUI/Classes/SignUpViewController/PFSignUpViewController.h +++ b/ParseUI/Classes/SignUpViewController/PFSignUpViewController.h @@ -21,6 +21,8 @@ #import +#import + #import #import @@ -125,7 +127,7 @@ extern NSString *const PFSignUpCancelNotification; @return A `BOOL` indicating whether the sign up should proceed. */ -- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info; +- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary PF_GENERIC(NSString *,NSString *)*)info; ///-------------------------------------- /// @name Responding to Actions @@ -145,8 +147,7 @@ extern NSString *const PFSignUpCancelNotification; @param signUpController The signup view controller where signup failed. @param error `NSError` object representing the error that occured. */ -- (void)signUpViewController:(PFSignUpViewController *)signUpController - didFailToSignUpWithError:(nullable NSError *)error; +- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(nullable NSError *)error; /** Sent to the delegate when the sign up screen is cancelled. diff --git a/ParseUI/Classes/Views/PFImageView.h b/ParseUI/Classes/Views/PFImageView.h index e5eea45..adabf56 100644 --- a/ParseUI/Classes/Views/PFImageView.h +++ b/ParseUI/Classes/Views/PFImageView.h @@ -21,13 +21,15 @@ #import +#import + #import NS_ASSUME_NONNULL_BEGIN typedef void(^PFImageViewImageResultBlock)(UIImage *__nullable image, NSError *__nullable error); -@class BFTask; +@class BFTask PF_GENERIC(__covariant BFGenericType); @class PFFile; /** @@ -49,7 +51,7 @@ typedef void(^PFImageViewImageResultBlock)(UIImage *__nullable image, NSError * @return The task, that encapsulates the work being done. */ -- (BFTask *)loadInBackground; +- (BFTask PF_GENERIC(UIImage *)*)loadInBackground; /** Initiate downloading of the remote image. diff --git a/ParseUI/Classes/Views/PFImageView.m b/ParseUI/Classes/Views/PFImageView.m index fe44076..ea8d2eb 100644 --- a/ParseUI/Classes/Views/PFImageView.m +++ b/ParseUI/Classes/Views/PFImageView.m @@ -47,8 +47,8 @@ - (void)setFile:(PFFile *)otherFile { #pragma mark - #pragma mark Load -- (BFTask *)loadInBackground { - BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource]; +- (BFTask PF_GENERIC(UIImage *)*)loadInBackground { + BFTaskCompletionSource PF_GENERIC(UIImage *)*source = [BFTaskCompletionSource taskCompletionSource]; [self loadInBackground:^(UIImage *image, NSError *error) { if (error) { [source trySetError:error]; diff --git a/ParseUIDemo/Swift/CustomViewControllers/ProductTableViewController/CustomProductTableViewController.swift b/ParseUIDemo/Swift/CustomViewControllers/ProductTableViewController/CustomProductTableViewController.swift index 30944cc..ed42217 100644 --- a/ParseUIDemo/Swift/CustomViewControllers/ProductTableViewController/CustomProductTableViewController.swift +++ b/ParseUIDemo/Swift/CustomViewControllers/ProductTableViewController/CustomProductTableViewController.swift @@ -27,14 +27,13 @@ import ParseUI class CustomProductTableViewController: PFProductTableViewController { override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - let product = objects?[indexPath.row] as? PFObject + let product = objects?[indexPath.row] if let identifier = product?["productIdentifier"] as? String where identifier == "Cooper" { PFPurchase.buyProduct(identifier) { error in if error == nil { UIAlertView(title: "Success!", message: "Yes!", delegate: nil, cancelButtonTitle: "OK").show() } } - return } super.tableView(tableView, didSelectRowAtIndexPath: indexPath) } diff --git a/ParseUIDemo/Swift/CustomViewControllers/QueryTableViewController/SectionedTableViewController.swift b/ParseUIDemo/Swift/CustomViewControllers/QueryTableViewController/SectionedTableViewController.swift index e90fcb0..ea20558 100644 --- a/ParseUIDemo/Swift/CustomViewControllers/QueryTableViewController/SectionedTableViewController.swift +++ b/ParseUIDemo/Swift/CustomViewControllers/QueryTableViewController/SectionedTableViewController.swift @@ -44,7 +44,7 @@ class SectionedTableViewController: PFQueryTableViewController { super.objectsDidLoad(error) sections.removeAll(keepCapacity: false) - if let objects = objects as? [PFObject] { + if let objects = objects { for object in objects { let priority = (object["priority"] as? Int) ?? 0 var array = sections[priority] ?? Array()