如何添加NSMutableArray
爲另一個NSMutableArray
如何NSMutableArray的添加爲objectAtIndex爲NSMutableArray的
我的代碼的對象(i)爲:
yearImages = [[NSMutableArray alloc]init];
tempImages = [[NSMutableArray alloc]init];
for(int i =0; i< [yearImagesName count]; i++)
{
for(int j=0; j<[totalImagesName count]; j++)
{
if ([[totalImagesName objectAtIndex:j] rangeOfString:[yearImagesName objectAtIndex:i]].location != NSNotFound)
{
[tempImages addObject:[totalImagesName objectAtIndex:j]];
}
}
[yearImages addObject:tempImages];
[tempImages removeAllObjects];
}
NSLog(@"\n\n year%@",[yearImages objectAtIndex:0]); // getting null result
在這裏,我需要添加tempImages爲對象(i)爲年圖像。
我需要的結果如下:
[yearImages objectAtIndex:i];// result need as arrayobjects here
ü得到什麼誤差R?發佈實際的編譯器錯誤... –
嘗試更改[yearImages insertObject:tempImages atIndex:i];到[yearImages addObject:tempImages]; – chancyWu
@Chancy:這兩者都是相同的。 –