//避免block中变量被循环引用
__block MakeOrderViewController *blockSelf = self;
chvc.calendarblock = ^(CalendarDayModel *model){
NSLog(@"%@",[model toString]);
if(model.style==CellDayTypeClick)
{
[blockSelf->dataArray addObject:model.toString];
NSSet *set = [NSSet setWithArray:blockSelf->dataArray];
dataArray=[[set allObjects] mutableCopy];
[blockSelf->dataArray sortUsingComparator:^NSComparisonResult(NSNumber *obj1, NSNumber *obj2) {
return [obj1 compare:obj2];
}];
}
else
{
[blockSelf->dataArray removeObject:model.toString];
}
};
网友评论