Skip to content

Instantly share code, notes, and snippets.

NSString *tempDirectoryTemplate =
[NSTemporaryDirectory() stringByAppendingPathComponent:@"myapptempdirectory.XXXXXX"];
const char *tempDirectoryTemplateCString =
[tempDirectoryTemplate fileSystemRepresentation];
char *tempDirectoryNameCString =
(char *)malloc(strlen(tempDirectoryTemplateCString) + 1);
strcpy(tempDirectoryNameCString, tempDirectoryTemplateCString);
char *result = mkdtemp(tempDirectoryNameCString);
if (!result)
static NSMutableDictionary* resources_ = nil;
@implementation GRResource
+ (void)initialize
{
static dispatch_once_t once;
dispatch_once(&once, ^{
resources_ = [NSMutableDictionary new];
});
- (void)addTask:(GRTask*)task
importer:(Class<GRImporter>)Importer
resources:(NSArray*)requiredResources
completionBlock:(GRImportCompletionBlock)complete
{
NSDictionary* taskInfo = [task dictionaryRepresentation];
GRImportCompletionBlock done = [complete copy];
[self addOperationWithBlock:^{
// ask plugin to generate an import block for this task
PS1="\w \$(~/bin/battery.sh) "