我正在尝试分配和初始化作为 NSObject (Circle) 一部分的 UIImageViews,并且我有一个由这些 Circles 组成的数组。但是,XCode 不喜欢我分配和初始化 UIImageViews。
这是代码:
//allocate and set circleArray
circleArray = [[NSMutableArray alloc] init];
for (int i = 0; i < 16; i++) {
[circleArray addObject:[Circle alloc]];
[[circleArray objectAtIndex:i] setTouched:0];
[[circleArray objectAtIndex:i] imageView] = [[UIImageView alloc] init]; //Problem Here: "Expression is not assignable"
}
//some code setting up the columns and beats shown below
for (int i = 0; i < 16; i++) {
[[[circleArray objectAtIndex:i] imageView] setFrame:CGRectMake([[circleArray objectAtIndex:i] column]*80-75, [[circleArray objectAtIndex:i] beat]*80+5, 70, 70)];
[self.view addSubview:[[circleArray objectAtIndex:i] imageView]];
if ([[circleArray objectAtIndex:i] beatMod] == 0) {
[[[circleArray objectAtIndex:i] imageView] setImage:redCircle];
}
else if ([[circleArray objectAtIndex:i] beatMod] == 0.5) {
[[[circleArray objectAtIndex:i] imageView] setImage:blueCircle];
}
else if ([[circleArray objectAtIndex:i] beatMod] == 0.25 || [[circleArray objectAtIndex:i] beatMod] == 0.75) {
[[[circleArray objectAtIndex:i] imageView] setImage:yellowCircle];
}
else {
[[[circleArray objectAtIndex:i] imageView] setImage:greenCircle];
}
}
如果我取出有错误的行,则屏幕上不会显示任何内容。我应该分配和初始化 UIImageViews 以使其显示,还是在分配和初始化 NSObject 时已经为我完成?我该如何解决?