This file contains hidden or 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
- (BOOL)play:(NSError **)error; | |
{ | |
NSAssert(_graph == NULL, @"Graph is already started"); | |
OSStatus status; | |
status = NewAUGraph(&_graph); | |
if (status != noErr) | |
goto failed; | |
This file contains hidden or 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
#define FAIL_ON_ERR(_X_) if ((status = (_X_)) != noErr) { goto failed; } | |
- (BOOL)play:(NSError **)error; | |
{ | |
NSAssert(_graph == NULL, @"Graph is already started"); | |
OSStatus status; | |
FAIL_ON_ERR(NewAUGraph(&_graph)); | |
FAIL_ON_ERR([self addOutputNode]); |
This file contains hidden or 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
#!/bin/sh | |
export DEVELOPER_DIR=/Developer | |
xcode_build="${DEVELOPER_DIR}/usr/bin/xcodebuild" | |
"$xcode_build" -version |
This file contains hidden or 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
% where python | |
/usr/bin/python | |
% python --version | |
Python 2.6.1 | |
% python | |
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) | |
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import sys | |
>>> for p in sys.path: |
This file contains hidden or 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
- (NSArray *)arrayForReading | |
{ | |
NSArray * array; | |
@synchronized (self) { | |
array = [[_array retain] autorelease]; | |
} | |
return array; | |
} | |
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len |
This file contains hidden or 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
typedef struct | |
{ | |
char * file; | |
int line; | |
} DDFileContext; | |
#define DDCurrentFileContext() ((DDFileContext) { .file = __FILE__, .line = __LINE__}) |
This file contains hidden or 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
@protocol DDAsyncTaskDelegate <NSObject> | |
- (void)setResult:(id)result; | |
- (void)setError:(NSError *)error; | |
@end | |
@protocol DDAsyncTask <NSObject> | |
- (void)startWithDelegate:(id<DDAsyncTaskDelegate>)delegate; | |
@end | |
id<DDFuture> DDStartAsyncTask(id<DDAsyncTask> asyncTask); |
This file contains hidden or 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
{ | |
NSOperationQueue * queue = [[[NSOperationQueue alloc] init] autorelease]; | |
NSURL * url = [NSURL URLWithString:@"http://www.example.com/"]; | |
id<DDFuture> futureData = [queue dd_submitCallableBlock:^id (NSError **error) { | |
NSData * data = [NSData dataWithContentsOfURL:url options:0 error:error]; | |
return data; | |
}]; | |
// This blocks for the result |
This file contains hidden or 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) connectUsingBlock:(void (^)(BOOL success, NSError *error))block { | |
block = [block copy]; | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^(void){ | |
NSError *err = nil; | |
BOOL success = YES; | |
dispatch_async(dispatch_get_main_queue(),^ { | |
block(success, err); |
This file contains hidden or 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
// Objective-C equivalent of Ruby's OptionParser | |
// http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html | |
[optionsParser on:@"-b" :@"--block ARG" :@"Set block arg" :^(id argument) { | |
NSLog(@"arg: %@", argument); | |
}]; |