如果数组的名称是指sello对象数组中sello对象的属性名称,我认为下面的代码会起作用。这就是我在视图控制器代码中输入的内容(matrixArray 是 sello 对象中的矩阵对象数组):
- (void)viewDidLoad {
[super viewDidLoad];
self.sello1 = [[Sello alloc] init];
self.sello2 = [[Sello alloc] init];
self.sello3 = [[Sello alloc] init];
self.sello4 = [[Sello alloc] init];
self.sello5 = [[Sello alloc] init];
self.sello6 = [[Sello alloc] init];
self.sello7 = [[Sello alloc] init];
self.sello8 = [[Sello alloc] init];
self.sello9 = [[Sello alloc] init];
self.sello10 = [[Sello alloc] init];
self.arr = [NSArray arrayWithObjects:self.sello1,self.sello2,self.sello3,self.sello4,self.sello5,self.sello6,self.sello7,self.sello8,self.sello9,self.sello10,nil];
}
-(void)viewDidAppear:(BOOL)animated {
NSNumber *num = @15;
for (Sello *aSello in self.arr) {
for (Matrix *aMatrix in aSello.matrixArray) {
if (aMatrix.somma == num.intValue) {
NSInteger indx = [self.arr indexOfObjectPassingTest:^BOOL(Sello *obj, NSUInteger idx, BOOL *stop) {
return obj == aSello;
}];
NSLog(@"%@", [NSString stringWithFormat:@"sello%d",indx+1]);
}
}
}
}