使用委託方法創建一個名爲mv的類的實例,我想要一個清除按鈕來刪除它的所有實例。無法刪除特定類的所有實例
所以我決定把它們添加到mutableArray:
- (void)viewDidLoad
{
[super viewDidLoad];
mvArray = [[NSMutableArray alloc] initWithCapacity:0];
方法:
-(void)addItemViewController:(VCDecorations *)controller didChooseImage:(UIImage *)image
{
if (image) {
self.imageDecoration = image;
mv = [[MovableImageView alloc]initWithImage:image];
[mvArray arrayByAddingObject:mv];
NSLog(@"%@",mvArray);
NSLog(@"%d",(integer_t)mvArray.count);
[self.view addSubview:mv];
}
和
- (IBAction)doClearBtn:(id)sender {
[mvArray removeAllObjects];
}
但似乎實例未添加。日誌是:
2013-10-18 16:06:38.149 manning1[13498:a0b] 0
2013-10-18 16:06:42.105 manning1[13498:a0b] ()
2013-10-18 16:06:42.106 manning1[13498:a0b] 0
2013-10-18 16:06:45.341 manning1[13498:a0b] ()
您確定您的視圖已加載?因爲你在viewDidLoad中初始化你的數組。 –