Skip to content

Commit

Permalink
BROKEN WIP first crack at obj-c lightweight generics
Browse files Browse the repository at this point in the history
  • Loading branch information
rentzsch committed Mar 4, 2016
1 parent f48402f commit c141670
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,23 @@ - (BOOL)isReadonly {

@implementation NSRelationshipDescription (collectionClassName)

- (NSString*)jr_CollectionClassStringWithOrderedClassName:(NSString*)orderedClassName
unorderedClassName:(NSString*)unorderedClassName
{
NSString *generic = [NSString stringWithFormat:@"<%@*>", self.destinationEntity.managedObjectClassName];
return [self jr_isOrdered]
? [orderedClassName stringByAppendingString:generic]
: [unorderedClassName stringByAppendingString:generic];
}

- (NSString*)mutableCollectionClassName {
return [self jr_isOrdered] ? @"NSMutableOrderedSet" : @"NSMutableSet";
return [self jr_CollectionClassStringWithOrderedClassName:@"NSMutableOrderedSet"
unorderedClassName:@"NSMutableSet"];
}

- (NSString*)immutableCollectionClassName {
return [self jr_isOrdered] ? @"NSOrderedSet" : @"NSSet";
return [self jr_CollectionClassStringWithOrderedClassName:@"NSOrderedSet"
unorderedClassName:@"NSSet"];
}

- (BOOL)jr_isOrdered {
Expand Down

0 comments on commit c141670

Please sign in to comment.