CocoaDev

Edit AllPages

Category for NSMatrix that allows moving rows and columns. Feel free to add anything else you find useful. Also check out DragMatrix, a very useful subclass of NSMatrix that can quickly be modified to accommodate dragging other types of cells (besides images).

Code for NSMatrix+CocoaDevUsersAdditions.h

#import <Cocoa/Cocoa.h>

@interface NSMatrix (CocoaDevUsersAdditions)

Code for NSMatrix+CocoaDevUsersAdditions.m

#import “NSMatrix+CocoaDevUsersAdditions.h”

@implementation NSMatrix (CocoaDevUsersAdditions)


Why make a copy of cellsInRow? Why not just pass in cellsInRow to -insertRow:withCells: ?

I think that immutable arrays don’t carry much of the “baggage” that mutable arrays do (e.g., current capacity, resizing capability). But I could be wrong. There won’t be any functional change if you don’t make a copy – I just thought it might help.

I think at best it will add a small overhead. I’ve changed the code :)

[[Category:CocoaDevUsersAdditions