Added Documentation
This commit is contained in:
@@ -8,23 +8,29 @@
|
||||
|
||||
#import "NSIndexPath+MPAdditions.h"
|
||||
|
||||
|
||||
|
||||
@implementation NSIndexPath (MPAdditions)
|
||||
|
||||
|
||||
- (NSUInteger)firstIndex
|
||||
{
|
||||
return [self indexAtPosition:0];
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)lastIndex
|
||||
{
|
||||
return [self indexAtPosition:self.length-1];
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)index
|
||||
{
|
||||
return [[self indexPathByRemovingLastIndex] indexPathByAddingIndex:index];
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingFirstIndex
|
||||
{
|
||||
if (self.length <= 1) {
|
||||
@@ -39,6 +45,7 @@
|
||||
return [[NSIndexPath alloc] initWithIndexes:newIndexes length:self.length-1];
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)index
|
||||
{
|
||||
NSUInteger newIndexes[self.length+1];
|
||||
@@ -49,8 +56,12 @@
|
||||
return [[NSIndexPath alloc] initWithIndexes:newIndexes length:self.length+1];
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathByIncrementingLastIndex
|
||||
{
|
||||
if (self.length < 1) {
|
||||
return [[NSIndexPath alloc] init];
|
||||
}
|
||||
NSUInteger lastIndex = [self lastIndex];
|
||||
lastIndex++;
|
||||
return [[self indexPathByRemovingLastIndex] indexPathByAddingIndex:lastIndex];
|
||||
@@ -58,29 +69,35 @@
|
||||
|
||||
- (NSIndexPath *)indexPathByDecrementingLastIndex
|
||||
{
|
||||
if (self.length < 1) {
|
||||
return [[NSIndexPath alloc] init];
|
||||
}
|
||||
NSUInteger lastIndex = [self lastIndex];
|
||||
lastIndex--;
|
||||
return [[self indexPathByRemovingLastIndex] indexPathByAddingIndex:lastIndex];
|
||||
}
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingIndexesFrom:(NSUInteger)length
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingIndexesFrom:(NSUInteger)from
|
||||
{
|
||||
NSIndexPath *indexPath = [[NSIndexPath alloc] init];
|
||||
for (NSUInteger position = 0; position < length; position++) {
|
||||
for (NSUInteger position = 0; position < MIN(from, self.length); position++) {
|
||||
indexPath = [indexPath indexPathByAddingIndex:[self indexAtPosition:position]];
|
||||
}
|
||||
return indexPath;
|
||||
}
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingIndexesTo:(NSUInteger)length
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingIndexesTo:(NSUInteger)to
|
||||
{
|
||||
NSIndexPath *indexPath = [[NSIndexPath alloc] init];
|
||||
for (NSUInteger position = length; position < self.length; position++) {
|
||||
for (NSUInteger position = to; position < self.length; position++) {
|
||||
indexPath = [indexPath indexPathByAddingIndex:[self indexAtPosition:position]];
|
||||
}
|
||||
return indexPath;
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)commonIndexPathWith:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSIndexPath *commonPath = [[NSIndexPath alloc] init];
|
||||
|
||||
Reference in New Issue
Block a user