Skip to content

Commit

Permalink
select appropriate class
Browse files Browse the repository at this point in the history
  • Loading branch information
kkazuo committed Dec 17, 2014
1 parent 420dc5b commit 8fbd9ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NSArray+map.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ @implementation NSArray (YOLO)
if (o)
mapped[jj++] = o;
}
return [[self.class alloc] initWithObjects:mapped count:jj];

Class immutableClass = [NSArray class];
Class mutableClass = [NSMutableArray class];
Class cls = [self isKindOfClass:mutableClass] ? mutableClass : immutableClass;
return [[cls alloc] initWithObjects:mapped count:jj];
};
}

Expand Down

0 comments on commit 8fbd9ff

Please sign in to comment.