gpt4 book ai didi

ios - 如何将 NSMutableArray 添加为 NSMutableArray 的 objectAtIndex

转载 作者:行者123 更新时间:2023-11-28 20:11:01 25 4
gpt4 key购买 nike

如何将 NSMutableArray 添加为另一个 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
  • 这里我需要为 yearImages 添加 tempImages 作为 (i) 的对象..

  • 我需要如下结果:


[yearImages objectAtIndex:i];// result need as arrayobjects here

最佳答案

添加对象后,您要从 tempImages 中删除对象,因此结果将是一个空数组。您应该添加 tempImages 的副本:[yearImages addObject:tempImages.copy](或 mutableCopy 如果你需要的话)

关于ios - 如何将 NSMutableArray 添加为 NSMutableArray 的 objectAtIndex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20262727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com