Skip to content

Instantly share code, notes, and snippets.

View gabriel's full-sized avatar

Gabriel Handford gabriel

View GitHub Profile
[Session started at 2008-12-30 00:10:13 -0800.]
2008-12-30 00:10:15.772 TestExceptionIPhone[8493:20b] Debug enabled
2008-12-30 00:10:15.830 TestExceptionIPhone[8493:20b] #0 0x92c5614b _NSExceptionSetRubyToken() (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
#1 0x9657ce3b objc_exception_throw() (/usr/lib/libobjc.A.dylib)
#2 0x92c55f2b +[NSException raise:format:arguments:] (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
#3 0x92c55f6a +[NSException raise:format:] (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
#4 0x002350 +[TestExceptionIPhoneAppDelegate applicationDidFinishLaunching:] (/Users/gabe/Library/Application Support/iPhone Simulator/User/Applications/586E48B6-B758-4DBD-A534-D6927DA74583/TestExceptionIPhone.app/TestExceptionIPhone)
#5 0x30a4e01a +[UIApplication performInitializationWithURL:asPanel:] (/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk/System/Libra
#ifdef DEBUG
#import <Foundation/NSDebug.h>
#import "GTMStackTrace.h"
void exceptionHandler(NSException *exception) {
NSLog(@"%@", GTMStackTraceFromException(exception));
}
#endif
int main(int argc, char *argv[]) {
// Invoke after 2 second delay (useful for simulating slow operations)
[[self gh_proxyAfterDelay:2.0] listWithOffset:40 limit:20];
// Invoke on main thread (if you ran on a separate thread or NSOperation
// and wanted to call back the delegate on the main thread)
[self listWithOffset:40 limit:20 delegate:[delegate_ gh_proxyOnMainThread:YES]];
// Later, after listing, the connection invokes the delegate back on the
// main thread
[delegate_ connection:self didListWithOffset:40 limit:20];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(listWithOffset:limit:)]];
[theInvocation setSelector:@selector(listWithOffset:limit:)];
[theInvocation setTarget:self];
NSInteger offset = 40;
[theInvocation setArgument:&offset atIndex:2];
NSInteger limit = 20;
[theInvocation setArgument:&limit atIndex:3];
[invocation performSelector:@selector(invoke) onThread:thread withObject:nil waitUntilDone:NO];
NSData *data = [NSData dataWithContentsOfFile:@"example.json"];
NSError *error = nil;
YAJLDocument *document = [[YAJLDocument alloc] initWithData:data parserOptions:0 error:&error];
// Access root element at document.root
NSLog(@"Root: %@", document.root);
[document release];
YAJLParser *parser = [[[YAJLParser alloc] initWithParserOptions:0] autorelease];
parser.delegate = self;
// A chunk of data comes...
YAJLParserStatus status = [parser parse:chunk1];
// 'status' should be YAJLParserStatusInsufficientData, if its not finished
if (parser.parserError) ...;
// Another chunk of data comes...
YAJLParserStatus status = [parser parse:chunk2];
NSData *data = [NSData dataWithContentsOfFile:@"example.json"];
YAJLParser *parser = [[YAJLParser alloc] initWithParserOptions:YAJLParserOptionsAllowComments];
parser.delegate = self;
[parser parse:data];
if (parser.parserError) {
NSLog(@"Error:\n%@", parser.parserError);
}
parser.delegate = nil;
# Goes to the current iPhone simulator app directory
alias simwd='cd "/Users/$USER/Library/Application Support/iPhone Simulator/User/Applications/" && cd `ls -t | cut -f 1 | head -1` && echo "Changed to `pwd`"'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Colors</key>
<dict>
<key>Background</key>
<string>0.078 0.078 0.078</string>
<key>InsertionPoint</key>
<string>1.000 1.000 1.000</string>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Colors</key>
<dict>
<key>Background</key>
<string>0.078 0.078 0.078</string>
<key>InsertionPoint</key>
<string>1.000 1.000 1.000</string>