-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathNSMutableArray+Utils.m
More file actions
40 lines (35 loc) · 857 Bytes
/
NSMutableArray+Utils.m
File metadata and controls
40 lines (35 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// NSMutableArray_Utils.m
//
// Created by Jiva DeVoe on 2/13/08.
// Copyright 2008 Random Ideas, LLC. All rights reserved.
//
#if ! __has_feature(objc_arc)
#error This file must be compiled with ARC.
#endif
#import "NSMutableArray+Utils.h"
#import "NSArray+Utils.h"
@implementation NSMutableArray (Utils)
-(void)unique;
{
NSMutableArray *uniqueContents = [NSArray arrayWithUniqueObjectsFromArray:self];
[self removeAllObjects];
[self addObjectsFromArray:uniqueContents];
}
- (void)moveObjectFromIndex:(NSUInteger)from toIndex:(NSUInteger)to
{
if (to != from)
{
id obj = [self objectAtIndex:from];
[self removeObjectAtIndex:from];
if (to >=[self count])
{
[self addObject:obj];
}
else
{
[self insertObject:obj atIndex:to];
}
}
}
@end