MoveArray.h@interface NSMutableArray (HF)
- (void)moveObjectFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex;
#import "MoveArray.h"
@implementation NSMutableArray (HF)
- (void)moveObjectFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex
{
if (toIndex != fromIndex && fromIndex < [self count] && toIndex< [self count]) {
id obj = [self objectAtIndex:fromIndex];[obj retain];
[self removeObjectAtIndex:fromIndex];
if (toIndex >= [self count]) {
[self addObject:obj];
} else {
[self insertObject:obj atIndex:toIndex];
}
[obj release];
}
}
@end:
作者:hufeng825 发表于2013-2-3 1:52:36 原文链接
阅读:104 评论:0 查看评论