我有这样的代码: 我想一些瓦莱斯存储在一年中的一天,我设定期限,例如15/05/2011 20/05/2011到的iOS:更新一个NSMutableArray
在viewDidLoad中: 我存储空值,那么我可以存储无处不在的值我想要在阵列中,我使用“定点值”:
appDelegate.years = [[NSMutableArray alloc] init];
for (int i = 0; i < 50; i++) // I set 50 years
{
[appDelegate.years insertObject:[NSNull null] atIndex:i];
}
months = [[NSMutableArray alloc] init];
for (int i = 0; i < 12; i++)
{
[months insertObject:[NSNull null] atIndex:i];
}
days = [[NSMutableArray alloc] init];
for (int i = 0; i < 31; i++)
{
[days insertObject:[NSNull null] atIndex:i];
}
在我的方法:
int firstDay = 15;
int lastDay = 20;
int firstMonth = 4;
int lastMonth = 4;
NSString *string = first; //this is the value that I want to store in the period
for (int i = firstMonth; i < lastMonth+1; i++)
{
for (int j = firstDay; j < lastDay+1; j++)
{
NSMutableArray *values = [[NSMutableArray alloc] init];
[values addObject:string];
[days replaceObjectAtIndex:j withObject: values];
[values release];
}
[months replaceObjectAtIndex:i withObject:days];
}
[appDelegate.years replaceObjectAtIndex:0 withObject:months]; //0 is 2011
OK,在这个代码我sto重新存储在我存储在数组“索引”中的一个数组“索引”中的数组“索引”中存储的数组“索引”中的一个数组“索引”中的数组“值”中的值,它工作正常;但在此之后,如果我想将另一个字符串存储在同一位置的数组值中?
例如:我有另一个NSString * string2 =“秒”,我想将这个字符串存储在同一天的位置,然后我想在同一天数组值与“第一”和“第二”,然后我可以' t do“[days replaceObjectAtIndex:j withObject:values];”但我能做什么呢?