使用委托方法创建名为 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] ( )