-
-
Save chamons/41de8ef6a64059ffdfd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppDelegate.m | |
// MachHack2 | |
// | |
// Created by Chris Hamons on 3/20/15. | |
// Copyright (c) 2015 Chris Hamons. All rights reserved. | |
// | |
#import "AppDelegate.h" | |
@import AppKit; | |
@import QuickLook; | |
@import Quartz; | |
@import GLKit; | |
@import SecurityInterface; | |
@interface AppDelegate () | |
@property (weak) IBOutlet NSWindow *window; | |
@end | |
@implementation AppDelegate | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
NSDatePicker * p = [NSDatePicker new]; | |
p.frame = NSMakeRect(0, 0, 200, 200); | |
p.datePickerElements = NSYearMonthDatePickerElementFlag; | |
p.datePickerMode = NSSingleDateMode; | |
p.timeZone = NSTimeZoneNameStyleStandard; | |
p.datePickerStyle = NSClockAndCalendarDatePickerStyle; | |
p.bordered = false; | |
p.dateValue = [NSDate date]; | |
p.delegate = self; | |
[self.window.contentView addSubview:p]; | |
} | |
- (void)applicationWillTerminate:(NSNotification *)aNotification { | |
// Insert code here to tear down your application | |
} | |
- (void)datePickerCell:(NSDatePickerCell *)aDatePickerCell validateProposedDateValue:(NSDate **)proposedDateValue timeInterval:(NSTimeInterval *)proposedTimeInterval | |
{ | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"YYYY-MM-dd"]; | |
NSLog(@"Date is %@",[formatter stringFromDate:*proposedDateValue]); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to your h file
@interface AppDelegate : NSObject <NSApplicationDelegate, NSDatePickerCellDelegate>