Skip to content

Commit 5a33bb6

Browse files
committed
Merge pull request #745 from ParsePlatform/nlutsenko.generics.relation
Add generics support to PFRelation.
2 parents 0284848 + c49b2ea commit 5a33bb6

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Parse/PFRelation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
1818
The `PFRelation` class that is used to access all of the children of a many-to-many relationship.
1919
Each instance of `PFRelation` is associated with a particular parent object and key.
2020
*/
21-
@interface PFRelation : NSObject
21+
@interface PFRelation<ObjectType : PFObject *> : NSObject
2222

2323
/**
2424
The name of the class of the target child objects.
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
3232
/**
3333
Returns a `PFQuery` object that can be used to get objects in this relation.
3434
*/
35-
- (PFQuery *)query;
35+
- (PFQuery<ObjectType> *)query;
3636

3737
///--------------------------------------
3838
#pragma mark - Modifying Relations
@@ -43,14 +43,14 @@ NS_ASSUME_NONNULL_BEGIN
4343
4444
@param object A `PFObject` object to add relation to.
4545
*/
46-
- (void)addObject:(PFObject *)object;
46+
- (void)addObject:(ObjectType)object;
4747

4848
/**
4949
Removes a relation to the passed in object.
5050
5151
@param object A `PFObject` object to add relation to.
5252
*/
53-
- (void)removeObject:(PFObject *)object;
53+
- (void)removeObject:(ObjectType)object;
5454

5555
@end
5656

Parse/PFRole.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
#import <Parse/PFObject.h>
1313
#import <Parse/PFSubclassing.h>
14+
#import <Parse/PFUser.h>
1415

1516
NS_ASSUME_NONNULL_BEGIN
1617

18+
@class PFRelation<ObjectType : PFObject *>;
19+
1720
/**
1821
The `PFRole` class represents a Role on the Parse server.
1922
`PFRoles` represent groupings of `PFUser` objects for the purposes of granting permissions
@@ -83,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
8386
(e.g. read or write access through ACLs). You can add or remove users from
8487
the role through this relation.
8588
*/
86-
@property (nonatomic, strong, readonly) PFRelation *users;
89+
@property (nonatomic, strong, readonly) PFRelation<PFUser *> *users;
8790

8891
/**
8992
Gets the `PFRelation` for the `PFRole` objects that are direct children of this role.
@@ -92,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
9295
(e.g. read or write access through ACLs). You can add or remove child roles
9396
from this role through this relation.
9497
*/
95-
@property (nonatomic, strong, readonly) PFRelation *roles;
98+
@property (nonatomic, strong, readonly) PFRelation<PFRole *> *roles;
9699

97100
@end
98101

Parse/PFRole.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ + (instancetype)roleWithName:(NSString *)name acl:(PFACL *)acl {
5151
@dynamic name;
5252

5353
// Dynamic synthesizers would use objectForKey, not relationForKey
54-
- (PFRelation *)roles {
54+
- (PFRelation<PFRole *> *)roles {
5555
return [self relationForKey:@keypath(PFRole, roles)];
5656
}
5757

58-
- (PFRelation *)users {
58+
- (PFRelation<PFUser *> *)users {
5959
return [self relationForKey:@keypath(PFRole, users)];
6060
}
6161

0 commit comments

Comments
 (0)