Update Examples

This commit is contained in:
WenchaoD 2016-10-16 14:27:55 +08:00
parent 4f8cfbfa91
commit 967ff6e47a
3 changed files with 49 additions and 2 deletions

View File

@ -58,4 +58,28 @@
}];
}
- (void)testFilter {
NSMutableArray<NSNumber *> *array = [NSMutableArray arrayWithCapacity:50];
for (int i = 0; i < 50; i++) {
[array addObject:@(i)];
}
[self measureBlock:^{
[array filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return [evaluatedObject compare:@25]==NSOrderedSame;
}]];
}];
}
- (void)testCache {
NSCache *c = [[NSCache alloc] init];
for (int i = 0; i < 50; i++) {
[c setObject:@(i) forKey:@(i)];
}
[self measureBlock:^{
[c objectForKey:@25];
}];
}
@end

View File

@ -61,6 +61,10 @@
view.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0];
self.view = view;
#define FULL_SCREEN 1
#if FULL_SCREEN
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width, self.view.bounds.size.height-self.navigationController.navigationBar.frame.size.height)];
calendar.backgroundColor = [UIColor whiteColor];
calendar.dataSource = self;
@ -73,6 +77,20 @@
[self.view addSubview:calendar];
self.calendar = calendar;
#else
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width, 300)];
calendar.backgroundColor = [UIColor whiteColor];
calendar.dataSource = self;
calendar.delegate = self;
calendar.allowsMultipleSelection = YES;
calendar.firstWeekday = 2;
calendar.appearance.caseOptions = FSCalendarCaseOptionsWeekdayUsesSingleUpperCase|FSCalendarCaseOptionsHeaderUsesUpperCase;
[self.view addSubview:calendar];
self.calendar = calendar;
#endif
UIBarButtonItem *todayItem = [[UIBarButtonItem alloc] initWithTitle:@"Today" style:UIBarButtonItemStylePlain target:self action:@selector(todayItemClicked:)];
UIBarButtonItem *lunarItem = [[UIBarButtonItem alloc] initWithTitle:@"Lunar" style:UIBarButtonItemStylePlain target:self action:@selector(lunarItemClicked:)];
@ -116,7 +134,12 @@
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
#if FULL_SCREEN
self.calendar.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), self.view.bounds.size.width, self.view.bounds.size.height-CGRectGetMaxY(self.navigationController.navigationBar.frame));
#else
self.calendar.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), self.view.bounds.size.width, 300);
#endif
}
- (void)dealloc
@ -164,7 +187,7 @@
}
}
if (_showsLunar) {
NSInteger day = [_lunarCalendar components:NSCalendarUnitDay fromDate:date].day;
NSInteger day = [_lunarCalendar component:NSCalendarUnitDay fromDate:date];
return _lunarChars[day-1];
}
return nil;

View File

@ -99,7 +99,7 @@
if (!_lunar) {
return nil;
}
NSInteger day = [_lunarCalendar components:NSCalendarUnitDay fromDate:date].day;
NSInteger day = [_lunarCalendar component:NSCalendarUnitDay fromDate:date];
return _lunarChars[day-1];
}