2
我有一個NSArray充滿在NSDate的格式約30日期,迭代的NSArray充滿日期,比較其他的NSArray
我需要做的就是創建一個從這個另一個數組,其中包含了一個布爾所有從第一次約會到最後約會的日期。
前陣1 1/1/11 11年3月1日 11年5月1日
陣列2 是 沒有 是 沒有 是
我需要這個tapku圖書館日曆
這是我到目前爲止,但我從來沒有變化
int i=0;
for (NSDate *date = [[startingDate copy] autorelease]; [date compare: endingDate] < 0;
date = [date dateByAddingTimeInterval:24 * 60 * 60]) {
NSLog(@"%@ in [%@,%@]", date, startingDate, endingDate);
int day1 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:[eventDates objectAtIndex:i]];
int day2 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:date];
if(day1-day2==0) {
NSLog(@"yeh");
i=i+1;
//add yes to array2
} else {
NSLog(@"nah");
NSLog(@"%i",i);
//add no to array 2
}
}
這幾乎是我想要的所以感謝,但似乎給了我一個越界例外 – user913059
如果你發佈的實際錯誤,它會更容易幫助你。此外,別忘了接受答案,以便其他人知道這是以後的幫助。 – msgambel
我放棄了這種方法,決定嘗試一種不同的方法,但現在又出現了另一個問題! [鏈接](http://stackoverflow.com/questions/7222488/why-does-the-array-only-contain-the-final-mark) – user913059