-2

我正在使用以下代码从以下代码创建标签NSMutableArray

CGRect punti = CGRectMake(270, 200, 50, 50);
CGRect punti2 = CGRectMake(370, 200, 50, 50);
CGRect punti3 = CGRectMake(470, 200, 50, 50);

[_Cordinate3lettere insertObject:[NSMutableArray arrayWithObjects:[NSValue valueWithCGRect:punti],[NSValue valueWithCGRect:punti],[NSValue valueWithCGRect:punti], nil] atIndex:0];

UILabel *label = [[UILabel alloc] init];
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)];

// Error occurs on line below
label.frame = [[_Cordinate3lettere objectAtIndexs:indexSet] CGRectValue];
label.text = @"a"; 
label.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
//label.font =
[self.view addSubview:label];

但是,以下行会产生错误。

label.frame = [[_Cordinate3lettere objectAtIndexs:indexSet] CGRectValue];

收到的错误是No visible @interface for NSMutableArray declares the selector "objectAtIndexs"

是什么导致了这个错误,我该如何解决?

4

2 回答 2

2

您的通话中有错字。方法名称是:

- (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes

不是objectAtIndexs

于 2013-07-10T17:55:37.000 回答
0

代替label.frame = [[_Cordinate3lettere objectAtIndexs:indexSet] CGRectValue];

和:

NSArray *frames = [_Cordinate3lettere objectAtIndexes:indexSet];
label.frame = [[frame objectAtIndex:0 /*or whatever index you want here*/] CGRectValue];
于 2013-07-10T17:56:23.143 回答