我正在尝试使用NSMutableDictionary
. _coordinateRecords
我在视图控制器的 viewDidLoad 函数中使用它创建了一个坐标网格(作为我的字典):
[self _loopOnCellWithIterator: (^(int iLooper, int jLooper)
{
int cellWidth = 10;
int space = 1;
[_coordinateRecords setObject: [NSIndexPath indexPathForRow: iLooper inSection: jLooper] forKey: [NSValue valueWithPointer: redCell]];
redCell = [[[UIView alloc] initWithFrame: CGRectMake(iLooper * (cellWidth + space) + 24.25,
jLooper * (cellWidth + space) + 110,
cellWidth, cellWidth)] init];
_cells[iLooper][jLooper] = redCell;
[redCell setBackgroundColor: [UIColor blueColor]];
[[self view] addSubview: redCell];
})];
使用这个块:
- (void)_loopOnCellWithIterator: (void(^)(int iLooper, int jLooper))iterator
{
for (int iLooper = 0; iLooper < kCellSize; iLooper++)
{
for (int jLooper = 0; jLooper < kCellSize; jLooper++)
{
iterator(iLooper, jLooper);
}
}
}
所以,我想知道如何调用我设置的字典中的对象。