0

メイン配列 ( arrayEvents) には、start_date、event_id、event_name などのフィールドを持つイベントのリストが含まれています。多くのイベントは、同じ日付で異なる時間に発生する可能性があります。そのため、特定の日付のイベントを表示するために、一意の日付 ( arrayDates) のみを使用して現在の日付 (currentDate月の 1 日から最後の日までの範囲) を確認して比較しています。ここまで終わりました。今私の問題は、arrayEvents後で比較するために更新する必要があるため、次のロジック...but I am in the middle of the seaを適用していて、どこに行くべきかわからないということです!

for(int i=0;i<[arrayDates count];i++) {
    NSDate *obj = [arrayDates objectAtIndex:i];
    if([obj isEqualToDate:currentDate]) {
        //This date has some events, we've done up to here.
        //Now taking indexes of same objects (that's same dates objects) from the arrayEvents
        NSIndexSet *indexesOfObjects = [arrayDates indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
            return [arrayEvents containsObject:obj];
        }];
        if([indexesOfObjects count] > 1) {
            //We found some objects into arrayEvents, now I have to update
            //those objects into arrayEvents.
            //How to achieve this?

            //My plan was to iterate each indexes and make update on arrayEvents 
            //but I can't do this, as I don't have access to each index from NSIndexSet.
        }
    }
}

[[arrayEvents objectsAtIndexes:indexesOfObjects] 
setValue:[arrayDates objectAtIndex:i] forKey:@"filter_date"];

動作しません。


参考、NSIndexSetオブジェクトのインデックスの指定方法は?しかし、私を助けません。

4

1 に答える 1