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

Commit a10d3cc

Browse files
committed
Merge pull request #213 from ParsePlatform/nlutsenko.generics
Add generic types to all public API.
2 parents 5aa6c26 + 8e7f14f commit a10d3cc

File tree

10 files changed

+41
-37
lines changed

10 files changed

+41
-37
lines changed

ParseUI/Classes/LogInViewController/PFLogInViewController.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24+
#import <Parse/PFConstants.h>
25+
2426
#import <ParseUI/ParseUIConstants.h>
2527
#import <ParseUI/PFLogInView.h>
2628

@@ -70,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
7072
7173
If unspecified, the default is basic facebook permissions.
7274
*/
73-
@property (nullable, nonatomic, copy) NSArray *facebookPermissions;
75+
@property (nullable, nonatomic, copy) NSArray PF_GENERIC(NSString *)*facebookPermissions;
7476

7577
/**
7678
The sign up controller if sign up is enabled.
@@ -161,8 +163,7 @@ shouldBeginLogInWithUsername:(NSString *)username
161163
@param logInController The login view controller where login failed.
162164
@param error `NSError` object representing the error that occured.
163165
*/
164-
- (void)logInViewController:(PFLogInViewController *)logInController
165-
didFailToLogInWithError:(nullable NSError *)error;
166+
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(nullable NSError *)error;
166167

167168
/**
168169
Sent to the delegate when the log in screen is cancelled.

ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24+
#import <Parse/PFConstants.h>
2425
#import <ParseUI/ParseUIConstants.h>
2526

2627
NS_ASSUME_NONNULL_BEGIN
2728

28-
@class BFTask;
29+
@class BFTask PF_GENERIC(__covariant BFGenericType);
2930
@class PFCollectionViewCell;
3031
@class PFObject;
3132
@class PFQuery;
@@ -126,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN
126127
/**
127128
The array of instances of `PFObject` that is used as a data source.
128129
*/
129-
@property (nonatomic, copy, readonly) NSArray *objects;
130+
@property (nonatomic, copy, readonly) NSArray PF_GENERIC(__kindof PFObject *)*objects;
130131

131132
/**
132133
Returns an object at a particular indexPath.
@@ -148,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN
148149
/**
149150
Removes all objects at the specified index paths, animated.
150151
*/
151-
- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes;
152+
- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexes;
152153

153154
///--------------------------------------
154155
/// @name Loading Data
@@ -159,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN
159160
160161
@return An awaitable task that completes when the reload succeeds
161162
*/
162-
- (BFTask *)loadObjects;
163+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects;
163164

164165
/**
165166
Loads the objects of the `PFObject.parseClassName` at the specified page and appends it to the
@@ -170,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
170171
171172
@return An awaitable task that completes when the reload succeeds
172173
*/
173-
- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear;
174+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear;
174175

175176
/**
176177
Loads the next page of objects, appends to table, and refreshes.
@@ -209,8 +210,8 @@ NS_ASSUME_NONNULL_BEGIN
209210
@return The cell that represents this object.
210211
*/
211212
- (nullable PFCollectionViewCell *)collectionView:(UICollectionView *)collectionView
212-
cellForItemAtIndexPath:(NSIndexPath *)indexPath
213-
object:(nullable PFObject *)object;
213+
cellForItemAtIndexPath:(NSIndexPath *)indexPath
214+
object:(nullable PFObject *)object;
214215

215216
/**
216217
Override this method to customize the view that allows the user to load the

ParseUI/Classes/QueryCollectionViewController/PFQueryCollectionViewController.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
static NSString *const PFQueryCollectionViewNextPageReusableViewIdentifier = @"nextPageView";
3737

3838
@interface PFQueryCollectionViewController () {
39-
NSMutableArray *_mutableObjects;
39+
NSMutableArray PF_GENERIC(PFObject *)*_mutableObjects;
4040

4141
BOOL _firstLoad; // Whether we have loaded the first set of objects
4242
NSInteger _currentPage; // The last page that was loaded
@@ -226,11 +226,11 @@ - (void)removeObjectsAtIndexPaths:(NSArray *)indexPaths {
226226
#pragma mark -
227227
#pragma mark Loading Data
228228

229-
- (BFTask *)loadObjects {
229+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects {
230230
return [self loadObjects:0 clear:YES];
231231
}
232232

233-
- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
233+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear {
234234
self.loading = YES;
235235
[self objectsWillLoad];
236236

ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24+
#import <Parse/PFConstants.h>
2425
#import <ParseUI/ParseUIConstants.h>
2526

2627
NS_ASSUME_NONNULL_BEGIN
2728

28-
@class BFTask;
29+
@class BFTask PF_GENERIC(__covariant BFGenericType);
2930
@class PFObject;
3031
@class PFQuery;
3132
@class PFTableViewCell;
@@ -148,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN
148149
/**
149150
The array of instances of `PFObject` that is used as a data source.
150151
*/
151-
@property (nullable, nonatomic, copy, readonly) NSArray *objects;
152+
@property (nullable, nonatomic, copy, readonly) NSArray PF_GENERIC(__kindof PFObject *)*objects;
152153

153154
/**
154155
Returns an object at a particular indexPath.
@@ -175,12 +176,12 @@ NS_ASSUME_NONNULL_BEGIN
175176
/**
176177
Removes all objects at the specified index paths, animated.
177178
*/
178-
- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes;
179+
- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexPaths;
179180

180181
/**
181182
Removes all objects at the specified index paths, with or without animation.
182183
*/
183-
- (void)removeObjectsAtIndexPaths:(nullable NSArray *)indexes animated:(BOOL)animated;
184+
- (void)removeObjectsAtIndexPaths:(nullable NSArray PF_GENERIC(NSIndexPath *)*)indexPaths animated:(BOOL)animated;
184185

185186
/**
186187
Clears the table of all objects.
@@ -192,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN
192193
193194
@return An awaitable task that completes when the reload succeeds
194195
*/
195-
- (BFTask *)loadObjects;
196+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *> *)*)loadObjects;
196197

197198
/**
198199
Loads the objects of the className at the specified page and appends it to the
@@ -203,7 +204,7 @@ NS_ASSUME_NONNULL_BEGIN
203204
204205
@return An awaitable task that completes when the reload succeeds
205206
*/
206-
- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear;
207+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *> *)*)loadObjects:(NSInteger)page clear:(BOOL)clear;
207208

208209
/**
209210
Loads the next page of objects, appends to table, and refreshes.
@@ -239,8 +240,8 @@ NS_ASSUME_NONNULL_BEGIN
239240
@return The cell that represents this object.
240241
*/
241242
- (nullable PFTableViewCell *)tableView:(UITableView *)tableView
242-
cellForRowAtIndexPath:(NSIndexPath *)indexPath
243-
object:(nullable PFObject *)object;
243+
cellForRowAtIndexPath:(NSIndexPath *)indexPath
244+
object:(nullable PFObject *)object;
244245

245246
/**
246247
Override this method to customize the cell that allows the user to load the
@@ -251,8 +252,7 @@ NS_ASSUME_NONNULL_BEGIN
251252
252253
@return The cell that allows the user to paginate.
253254
*/
254-
- (nullable PFTableViewCell *)tableView:(UITableView *)tableView
255-
cellForNextPageAtIndexPath:(NSIndexPath *)indexPath;
255+
- (nullable PFTableViewCell *)tableView:(UITableView *)tableView cellForNextPageAtIndexPath:(NSIndexPath *)indexPath;
256256

257257
@end
258258

ParseUI/Classes/QueryTableViewController/PFQueryTableViewController.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
4545
@end
4646

4747
@interface PFQueryTableViewController () {
48-
NSMutableArray *_mutableObjects;
48+
NSMutableArray PF_GENERIC(PFObject *)*_mutableObjects;
4949

5050
BOOL _firstLoad; // Whether we have loaded the first set of objects
5151
NSInteger _currentPage; // The last page that was loaded
@@ -212,11 +212,11 @@ - (void)clear {
212212
_currentPage = 0;
213213
}
214214

215-
- (BFTask *)loadObjects {
215+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects {
216216
return [self loadObjects:0 clear:YES];
217217
}
218218

219-
- (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
219+
- (BFTask PF_GENERIC(NSArray<__kindof PFObject *>*)*)loadObjects:(NSInteger)page clear:(BOOL)clear {
220220
self.loading = YES;
221221
[self objectsWillLoad];
222222

@@ -554,7 +554,7 @@ - (void)_refreshControlValueChanged:(UIRefreshControl *)refreshControl {
554554
#pragma mark -
555555
#pragma mark Accessors
556556

557-
- (NSArray *)objects {
557+
- (NSArray PF_GENERIC(__kindof PFObject *)*)objects {
558558
return _mutableObjects;
559559
}
560560

ParseUI/Classes/SignUpViewController/PFSignUpViewController.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24+
#import <Parse/PFConstants.h>
25+
2426
#import <ParseUI/ParseUIConstants.h>
2527
#import <ParseUI/PFSignUpView.h>
2628

@@ -125,7 +127,7 @@ extern NSString *const PFSignUpCancelNotification;
125127
126128
@return A `BOOL` indicating whether the sign up should proceed.
127129
*/
128-
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info;
130+
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary PF_GENERIC(NSString *,NSString *)*)info;
129131

130132
///--------------------------------------
131133
/// @name Responding to Actions
@@ -145,8 +147,7 @@ extern NSString *const PFSignUpCancelNotification;
145147
@param signUpController The signup view controller where signup failed.
146148
@param error `NSError` object representing the error that occured.
147149
*/
148-
- (void)signUpViewController:(PFSignUpViewController *)signUpController
149-
didFailToSignUpWithError:(nullable NSError *)error;
150+
- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(nullable NSError *)error;
150151

151152
/**
152153
Sent to the delegate when the sign up screen is cancelled.

ParseUI/Classes/Views/PFImageView.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24+
#import <Parse/PFConstants.h>
25+
2426
#import <ParseUI/ParseUIConstants.h>
2527

2628
NS_ASSUME_NONNULL_BEGIN
2729

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

30-
@class BFTask;
32+
@class BFTask PF_GENERIC(__covariant BFGenericType);
3133
@class PFFile;
3234

3335
/**
@@ -49,7 +51,7 @@ typedef void(^PFImageViewImageResultBlock)(UIImage *__nullable image, NSError *
4951
5052
@return The task, that encapsulates the work being done.
5153
*/
52-
- (BFTask *)loadInBackground;
54+
- (BFTask PF_GENERIC(UIImage *)*)loadInBackground;
5355

5456
/**
5557
Initiate downloading of the remote image.

ParseUI/Classes/Views/PFImageView.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ - (void)setFile:(PFFile *)otherFile {
4747
#pragma mark -
4848
#pragma mark Load
4949

50-
- (BFTask *)loadInBackground {
51-
BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource];
50+
- (BFTask PF_GENERIC(UIImage *)*)loadInBackground {
51+
BFTaskCompletionSource PF_GENERIC(UIImage *)*source = [BFTaskCompletionSource taskCompletionSource];
5252
[self loadInBackground:^(UIImage *image, NSError *error) {
5353
if (error) {
5454
[source trySetError:error];

ParseUIDemo/Swift/CustomViewControllers/ProductTableViewController/CustomProductTableViewController.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ import ParseUI
2727
class CustomProductTableViewController: PFProductTableViewController {
2828

2929
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
30-
let product = objects?[indexPath.row] as? PFObject
30+
let product = objects?[indexPath.row]
3131
if let identifier = product?["productIdentifier"] as? String where identifier == "Cooper" {
3232
PFPurchase.buyProduct(identifier) { error in
3333
if error == nil {
3434
UIAlertView(title: "Success!", message: "Yes!", delegate: nil, cancelButtonTitle: "OK").show()
3535
}
3636
}
37-
return
3837
}
3938
super.tableView(tableView, didSelectRowAtIndexPath: indexPath)
4039
}

ParseUIDemo/Swift/CustomViewControllers/QueryTableViewController/SectionedTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SectionedTableViewController: PFQueryTableViewController {
4444
super.objectsDidLoad(error)
4545

4646
sections.removeAll(keepCapacity: false)
47-
if let objects = objects as? [PFObject] {
47+
if let objects = objects {
4848
for object in objects {
4949
let priority = (object["priority"] as? Int) ?? 0
5050
var array = sections[priority] ?? Array()

0 commit comments

Comments
 (0)