如何在指定索引处添加对象? 在我的问题中
NSMutableArray *substring
交替包含索引和对象,我需要str
根据从该数组获得的索引将其添加到另一个数组中。
NSMutableArray *str=[NSMutableArray new];
if ([substrings containsObject:@"Category-Sequence:"])
{
NSString *index=[substrings objectAtIndex:5];
//[substrings objectAtIndex:5]
gives me integer position at which I need to add object in `str` array,
gives 5,4,8,2,7,1 etc
NSString *object=[substrings objectAtIndex:1];
//[substrings objectAtIndex:1] gives object,gives NSString type of object
[str insertObject:object atIndex:(index.intValue)];
}
请提出一些方法来实现它。
提前致谢!