0

我正在尝试使用 Tapku 图书馆,我需要标记我有活动的日期。

我的 api 结果是:

  "month":08; 
 "calendarDays": [
    "17",
    "24"
]

下面是我的代码:

- (NSArray*)calendarMonthView:(TKCalendarMonthView *)monthView marksFromDate:(NSDate *)startDate toDate:(NSDate *)lastDate {

    NSMutableArray *marks = [NSMutableArray array];


    SCCalenderElemDaysConnection *connection=[[SCCalenderElemDaysConnection alloc]init];
    [connection obtieneListadoCalenderElemDays:^(SCCalenderElems *CalArr) {
        self.CalenderDays=CalArr.calenderDays;

        self.CalenderDays = [NSArray arrayWithObjects:
                             [NSString stringWithFormat:@"2013-09-%@ 22:00:00 +0000",[self.CalenderDays objectAtIndex:0]],@"2013-09-12 22:00:00 +0000", nil];


        NSDate *d = startDate;

        while(YES){

            if ([self.CalenderDays containsObject:[d description]]) {
                [marks addObject:[NSNumber numberWithBool:YES]];
            } else {
                [marks addObject:[NSNumber numberWithBool:NO]];
            }

            NSDateComponents *info = [d dateComponentsWithTimeZone:self.monthView.timeZone];
            info.day++;
            d = [NSDate dateWithDateComponents:info];
            if([d compare:lastDate]==NSOrderedDescending) break;
        }
        NSLog(@"Marks %@",marks); // here marks have values


    } :selectedMonth conToken:@"test" failure:^(NSError *error) {
        NSLog(@"ERROR CALENDER DAYS %@",error);
    }];


      NSLog(@"MarkArray %@",marks); //marks null value

    return [NSArray arrayWithArray:marks];
}

我的块外数组是空的。我该如何解决这个问题?

提前致谢。

4

1 回答 1

0

我已经解决了我的问题。我需要重新加载我的日历。因为我的块是异步的。

   .....


[self.monthview reloadData];   // is my solution


} :selectedMonth conToken:@"test" failure:^(NSError *error) {
    NSLog(@"ERROR CALENDER DAYS %@",error);
}];

谢谢。

于 2013-09-25T13:32:05.333 回答