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
- (NSURL *)applicationSupportDirectory { | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); | |
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory(); | |
NSString *path = [basePath stringByAppendingPathComponent:@"YourAppName"]; | |
NSFileManager *fm = [NSFileManager defaultManager]; | |
if (![fm fileExistsAtPath:path isDirectory:NULL]) { | |
[fm createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; | |
} | |
return [NSURL fileURLWithPath:path]; |
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
@interface NSImage (PrefPaneExtensions) | |
+ (NSImage*)prefPaneImageNamed:(NSString*)name; | |
@end |
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
// | |
// SNRRestorationManager.h | |
// Sonora | |
// | |
// Created by Indragie Karunaratne on 2012-08-19. | |
// | |
#import <Foundation/Foundation.h> | |
@protocol SNRRestorableState <NSObject> |
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
// | |
// SNRDiscogsEngine.h | |
// Sonora | |
// | |
// Created by Indragie Karunaratne on 11-11-18. | |
// | |
#import <Foundation/Foundation.h> | |
@interface SNRDiscogsEngine : NSObject |
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
// Super simple key logger that uses a CGEventTap to log | |
// the unicode strings for each key down event | |
// Doesn't handle special keys (enter, backspace, etc.) | |
#include <stdio.h> | |
#import <Carbon/Carbon.h> | |
#import <ApplicationServices/ApplicationServices.h> | |
CGEventRef loggerCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void* context) | |
{ |
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
// | |
// FGOManagedObjectContextStack.h | |
// | |
// Created by Indragie Karunaratne on 2012-12-23. | |
// Copyright (c) 2012 Indragie Karunaratne. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface FGOManagedObjectContextStack : NSObject |
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
// In an NSSplitView subclass | |
- (void)drawDividerInRect:(NSRect)rect | |
{ | |
[super drawDividerInRect:NSIntegralRect(rect)]; | |
} | |
// In NSSplitViewDelegate implementation | |
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex |
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
- (void)fetchWithRequest:(NSFetchRequest *)request | |
completion:(void(^)(NSArray *results, NSError *error))handler | |
{ | |
[request setResultType:NSManagedObjectIDResultType]; | |
void (^executeHandler)(NSArray *, NSError *) = ^(NSArray *results, NSError *error){ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (handler) handler(results, error); | |
}); | |
}; | |
[self.backgroundContext performBlock:^{ |
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
// | |
// FGOManagedObjectContextStack.h | |
// | |
// Created by Indragie Karunaratne on 2012-12-23. | |
// | |
#import <Foundation/Foundation.h> | |
typedef void (^FGOConfigurationBlock)(id); |
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
NSString *sanitizedString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSURL *URL = [NSURL URLWithString:sanitizedString]; |