0

以前に追加されたオブジェクトを置き換える配列。

array=[[NSMutableArray alloc]init];

NSNumber * index;

AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
if(delegate.counter!=NumberImages.count)
{
    NSLog(@"%d",delegate.counter);

    imgview.tag=delegate.counter;

    NSLog(@"%ld",(long)imgview.tag);

    index=[[NSNumber alloc]initWithInt:[[firstNo objectAtIndex:imgview.tag]integerValue]];

    //int a=[[firstNo objectAtIndex:imgview.tag]integerValue];

    NSLog(@"%@",index);

    NSLog(@"%@",array);
}

[array addObject:index];

NSLog(@"%@",array);

問題は、オブジェクトを挿入すると、以前の既存のオブジェクトが置き換えられることです。

どうすればいいですか?

4

3 に答える 3

0
if (!array) {
         array=[[NSMutableArray alloc]init];
}

お役に立てると思います。

于 2013-07-16T13:03:45.510 に答える