Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Add generic types to all public API. #213

Merged
merged 6 commits into from
Dec 7, 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
7 changes: 4 additions & 3 deletions ParseUI/Classes/LogInViewController/PFLogInViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#import <UIKit/UIKit.h>

#import <Parse/PFConstants.h>

#import <ParseUI/ParseUIConstants.h>
#import <ParseUI/PFLogInView.h>

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

#import <UIKit/UIKit.h>

#import <Parse/PFConstants.h>
#import <ParseUI/ParseUIConstants.h>

NS_ASSUME_NONNULL_BEGIN

@class BFTask;
@class BFTask PF_GENERIC(__covariant BFGenericType);
@class PFCollectionViewCell;
@class PFObject;
@class PFQuery;
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

#import <UIKit/UIKit.h>

#import <Parse/PFConstants.h>
#import <ParseUI/ParseUIConstants.h>

NS_ASSUME_NONNULL_BEGIN

@class BFTask;
@class BFTask PF_GENERIC(__covariant BFGenericType);
@class PFObject;
@class PFQuery;
@class PFTableViewCell;
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -554,7 +554,7 @@ - (void)_refreshControlValueChanged:(UIRefreshControl *)refreshControl {
#pragma mark -
#pragma mark Accessors

- (NSArray *)objects {
- (NSArray PF_GENERIC(__kindof PFObject *)*)objects {
return _mutableObjects;
}

Expand Down
7 changes: 4 additions & 3 deletions ParseUI/Classes/SignUpViewController/PFSignUpViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#import <UIKit/UIKit.h>

#import <Parse/PFConstants.h>

#import <ParseUI/ParseUIConstants.h>
#import <ParseUI/PFSignUpView.h>

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions ParseUI/Classes/Views/PFImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

#import <UIKit/UIKit.h>

#import <Parse/PFConstants.h>

#import <ParseUI/ParseUIConstants.h>

NS_ASSUME_NONNULL_BEGIN

typedef void(^PFImageViewImageResultBlock)(UIImage *__nullable image, NSError *__nullable error);

@class BFTask;
@class BFTask PF_GENERIC(__covariant BFGenericType);
@class PFFile;

/**
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions ParseUI/Classes/Views/PFImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down