NSMatrix bindings mayhem -
I want to use the NSMatrix
so that a 6- day work for employees (columns) week (6 rows) Fwaiai, since NSTableView
does not cell-to-cell drag-and-drop support, oh I have to instead use NSMatrix
.
However, I want to use NSArray
content
for coke binding, NSMatrix .
If I have an employee, then there will be 6 items in my array. However, if I add another employee, then the data of the employee 1 also needs to be captured on the array index (0-2-4-6-8-10), and the data in employee 2 is a weird index (1 -3-5-7- 9-11).
If I want to remove Employee 1 now, then I have to remove 10,8,6,4,2,0 items in that order!
Yowza
Am I reading this right? Is anyone else related to this madness? Actually, my initial arguments were correct - that is, with the built-in array for the content,
NSMatrix
returns
That the material is from top to bottom to top, an array of 10 elements in 5x2 matrix will be kept with these indices:
0 1 2 3 4 5 6 7 8 9 > so I pieces of a couple of code sharing with you ... for example, [self insColAtIndex: self.matrix.numberOfColumns] a call to a new one with new items Mat In the X, the last column added with the
"X" on this result:
0 1 2 3 4 x 5 6 7 8 9x
< p> Any early-size allocation with NSMatrix
to the desired height of the N rows with at least 1 column, here NSArrayController
a sub-classified control in two ways NSMatrix
and its content array organizations work together: NSMatrix column inserted on index (zero based) - (zero) insColAtIn Dex: (NSInteger Index) {NSInteger colCount = self.matrix.numberOfColumns; If (index & lieutenant; 0; index; callback) returns; NSInteger rowCount = self.matrix.numberOfRows; [Self. Matrix adcomm]; (NSInteger i = 0; i & lt; rowCount; i ++) [self insert object: [[Anssiel light] Int] Aararanned object Index: Index + Kolkount * i + i]; } // Remove the NSMatrix column on the index (zero-based) - (zero) delColAtIndex: (NSInteger) index {NSInteger colCount = self.matrix.numberOfColumns; If (index index = colCount) returns; NSInteger rowCount = self.matrix.numberOfRows; [Self. Remove matrix column: index]; (NSInteger i = rowCount-1; i & gt; = 0; i--) to (remove themselves Objektatarended object Index: Index + Colkount * i];}
I think I have a NSMutableIndexSet
could be made with the array index hit insertObjects with an array of NSMatrix at once (: atArrangedObjectIndexes:
and removeObjectsAtArrangedObjectIndexes: < / Code>), but it seemed more troublesome that it was worth it.
The code to insert / delete rows continuously with the array (much easier) Areas are left as) exercise for the reader; -)
Comments
Post a Comment