Created
August 1, 2017 21:27
-
-
Save groob/36bb7d37d3f6bd68fb8c49d816ec0fcd 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
package main | |
/* | |
#cgo darwin CFLAGS: -DDARWIN -x objective-c | |
#cgo darwin LDFLAGS: -framework Cocoa | |
#import <Cocoa/Cocoa.h> | |
@interface ManageHandler : NSObject<NSUserNotificationCenterDelegate> | |
@property (retain) NSUserDefaults *userDefaults; | |
@end | |
ManageHandler * uncDelegate; | |
@implementation ManageHandler | |
-(instancetype) init { | |
self = [super init]; | |
if (self) { | |
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"ManagedInstalls"]; | |
[_userDefaults addObserver:self | |
forKeyPath:@"LastCheckDate" | |
options:NSKeyValueObservingOptionNew | |
context:NULL]; | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
[_userDefaults removeObserver:self forKeyPath:@"LastCheckDate"]; | |
[super dealloc]; | |
} | |
- (void)observeValueForKeyPath:(NSString *)keyPath | |
ofObject:(id)object | |
change:(NSDictionary *)change | |
context:(void *)context { | |
NSLog(@"changed"); | |
NSString * str = [_userDefaults stringForKey:@"LastCheckDate"]; | |
NSLog(@"%@", str); | |
} | |
@end | |
void Prefs() { | |
NSUserDefaults * userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"ManagedInstalls"]; | |
NSString * str = [userDefaults stringForKey:@"LastCheckDate"]; | |
NSLog(@"%@", str); | |
uncDelegate = [[ManageHandler alloc] init]; | |
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: uncDelegate]; | |
[[NSRunLoop mainRunLoop] run]; | |
} | |
*/ | |
import "C" | |
import "fmt" | |
func main() { | |
fmt.Println("start loop") | |
C.Prefs() | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment