Edit AllPages

Sure looks bare up here with no comments.

OK, here’s one:

19 March 2009 - Added moveObject: toIndex: (Just to keep things alive!) – this had a bug in it, now fixed –JediKnil

4 June 2010 - moveObject: toIndex: (Fixed yet again!)

Source for NSMutableArray +CocoaDevUsersAdditions.h :

#import <Foundation/Foundation.h>

@interface NSMutableArray (CocoaDevUsersAdditions)

// Method for serializing an NSMutableArray object to a NSData in the form of a property list


Source for NSMutableArray+CocoaDevUsersAdditions.m :

#import “NSMutableArray+CocoaDevUsersAdditions.h”

@implementation NSMutableArray (CocoaDevUsersAdditions)

-(void)insertObjectsFromArray:(NSArray *)anArray atIndex:(int)index { int oldCount = [self count]; int cursor = index; int i;

[self addObjectsFromArray:anArray];

for (i = oldCount; i < [self count]; i++) { [self exchangeObjectAtIndex:i withObjectAtIndex: cursor]; cursor++; }

// The above doesn’t work for arbitrary insertions!?! I propose instead: // NSMutableArray* newOrdering = [NSMutableArray array]; // [newOrdering addObjectsFromArray:[self subarrayWithRange:NSMakeRange(0, anIndex); // [newOrdering addObjectsFromArray:anArray]; // [newOrdering addObjectsFromArray:[self subarrayWithRange:NSMakeRange(anIndex, [self count]-anIndex)]]; // [self setArray:newOrdering]; }