我已经像这样初始化了一个 NSMutableArray:
tileArray = [[NSMutableArray alloc]initWithObjects:
(tile1,tile2,tile3,tile4,tile5,tile6,tile7,tile8,tileBlank), nil];
我正在尝试通过执行以下操作打印出数组的大小:
NSLog(@"Size2: %i", [tileArray count]);
它告诉我大小为 0。这是什么原因造成的?
.h 文件
@interface STView : UIView{
NSMutableArray *tileArray;
TileView *tile1;
TileView *tile2;
TileView *tile3;
TileView *tile4;
TileView *tile5;
TileView *tile6;
TileView *tile7;
TileView *tile8;
TileView *tileBlank;
int width;
int height;
}
- (void) getScreenSize;
@end
瓦片视图.m
- (id)initWithFrame:(CGRect)frame withImageNamed: (NSString*) imageName{
if (self = [super initWithFrame:frame]) {
//initilization code
image = [[UIImageView alloc]
initWithImage: [UIImage imageNamed: imageName]];
image.frame = self.bounds;
image.opaque = YES;
[self addSubview:image];
} return self;
}