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
#ifdef DEBUG | |
#import <Foundation/NSDebug.h> | |
#import "GTMStackTrace.h" | |
void exceptionHandler(NSException *exception) { | |
NSLog(@"%@", GTMStackTraceFromException(exception)); | |
} | |
#endif | |
int main(int argc, char *argv[]) { |
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
// 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]; |
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
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]; |
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
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]; |
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
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]; |
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
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; |
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
# 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`"' |
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
<?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> |
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
<?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> |
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
// | |
// GTMStackTrace.h | |
// | |
// Copyright 2007-2008 Google Inc. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
// use this file except in compliance with the License. You may obtain a copy | |
// of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 |