Skip to content

Add generics support to PFRelation. #745

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 2 commits into from
Jan 8, 2016
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
8 changes: 4 additions & 4 deletions Parse/PFRelation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
The `PFRelation` class that is used to access all of the children of a many-to-many relationship.
Each instance of `PFRelation` is associated with a particular parent object and key.
*/
@interface PFRelation : NSObject
@interface PFRelation<ObjectType : PFObject *> : NSObject

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

///--------------------------------------
#pragma mark - Modifying Relations
Expand All @@ -43,14 +43,14 @@ NS_ASSUME_NONNULL_BEGIN

@param object A `PFObject` object to add relation to.
*/
- (void)addObject:(PFObject *)object;
- (void)addObject:(ObjectType)object;

/**
Removes a relation to the passed in object.

@param object A `PFObject` object to add relation to.
*/
- (void)removeObject:(PFObject *)object;
- (void)removeObject:(ObjectType)object;

@end

Expand Down
7 changes: 5 additions & 2 deletions Parse/PFRole.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

#import <Parse/PFObject.h>
#import <Parse/PFSubclassing.h>
#import <Parse/PFUser.h>

NS_ASSUME_NONNULL_BEGIN

@class PFRelation<ObjectType : PFObject *>;

/**
The `PFRole` class represents a Role on the Parse server.
`PFRoles` represent groupings of `PFUser` objects for the purposes of granting permissions
Expand Down Expand Up @@ -83,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
(e.g. read or write access through ACLs). You can add or remove users from
the role through this relation.
*/
@property (nonatomic, strong, readonly) PFRelation *users;
@property (nonatomic, strong, readonly) PFRelation<PFUser *> *users;

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

@end

Expand Down
4 changes: 2 additions & 2 deletions Parse/PFRole.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ + (instancetype)roleWithName:(NSString *)name acl:(PFACL *)acl {
@dynamic name;

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

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

Expand Down