我有這樣的代碼: 我想一些瓦萊斯存儲在一年中的一天,我設定期限,例如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];」但我能做什麼呢?