UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SudokuCell.png"]];
NSLog(@"%@", image);
[[self.blocks objectAtIndex:row] setObject:image atIndex:col];
NSLog(@"%@", [[self.blocks objectAtIndex:row] objectAtIndex:col]);
是我正在运行的代码。第一个 NSLog 打印 UIImageView 对象,第二个 NSLog 打印 (null)。为什么第二个 NSLog 打印的内容与第一个不一样?
数组 self.blocks 被初始化为:
self.blocks = [[NSMutableArray alloc] initWithCapacity: 9];
for (int i = 0; i < 9; i++)
{
[self.blocks addObject:[[NSMutableArray alloc]initWithCapacity:9]];
}