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
| #!/usr/sbin/dtrace -s | |
| /* Run like: | |
| % sudo csh | |
| # ./spy.d $PROCESS_ID [$INTERESTING_PROBEPROV] | |
| Prints a line of dashes every 5 seconds to delineate different experiments. | |
| */ | |
| #pragma D option quiet |
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
| #import <stdio.h> | |
| // clang -g -Wall -o old-days old-days.m | |
| typedef struct Rect { | |
| int x, y, w, h; | |
| } Rect; | |
| typedef enum { |
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
| #import <Foundation/Foundation.h> | |
| // clang -g -Wall -framework Foundation -o someObject someObject.m | |
| @interface SomeObject : NSObject | |
| - (void) doSome: (id) stuff for: (id) reasons; | |
| @end // SomeObject |
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
| #import <Foundation/Foundation.h> | |
| // clang -g -Wall -framework Foundation -o signature signature.m | |
| // A class with a vararg, and non-vararg method, to see if the method signatures | |
| // are different. (don't expect them to be, but ya never know...) | |
| @interface VarBork : NSObject | |
| - (id) gronkVar: (float) hoover, ...; | |
| - (id) gronk: (float) hoover; |
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
| #import <Foundation/Foundation.h> | |
| // Wrap up a call to rangeOfCharacterFromSet:options:range: in an invocation. | |
| // clang -g -Wall -framework Foundation -o invocation invocation.m | |
| // Little utility to dump out a method signature. | |
| static void printSignature (NSMethodSignature *signature) { | |
| NSLog (@"%ld arguments", [signature numberOfArguments]); | |
| for (NSUInteger i = 0; i < [signature numberOfArguments]; i++) { |
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
| #import <Foundation/Foundation.h> | |
| // Call a method through a cached IMP pointer. | |
| // clang -g -Wall -framework Foundation -o imp imp.m | |
| int main (void) { | |
| @autoreleasepool { | |
| NSString *string = @"Bork"; |
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
| #import <Foundation/Foundation.h> | |
| // clang -g -Wall -framework Foundation -o defaults-death defaults-death.m | |
| int main (void) { | |
| @autoreleasepool { | |
| NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; | |
| NSDictionary *defaultDefaults = @{ | |
| @"spoon" : @"waffle" |
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
| #import <Foundation/Foundation.h> | |
| // clang -g -fobjc-arc -Wall -framework Foundation -o marsupial marsupial.m | |
| @interface NSObject (AllThingsCanDance) | |
| - (void) wombatDance: (int) repetitions; | |
| @end | |
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
| #import <Foundation/Foundation.h> | |
| // clang++ -DCOVER_METHODS=1 -fobjc-arc -g -ObjC++ -Wall -framework Foundation -o machinery machinery.cpp | |
| // clang++ -DFORWARD_INVOCATION=1-fobjc-arc -g -ObjC++ -Wall -framework Foundation -o machinery machinery.cpp | |
| // clang++ -DFORWARDING_TARGET=1-fobjc-arc -g -ObjC++ -Wall -framework Foundation -o machinery machinery.cpp | |
| /* | |
| #define COVER_METHODS 0 | |
| #define FORWARD_INVOCATION 0 | |
| #define FORWARDING_TARGET 0 |
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
| #import <Foundation/Foundation.h> | |
| #import <objc/runtime.h> | |
| #import "typestring.h" | |
| // clang -g -fobjc-arc -Wall -framework Foundation -o runtime typestring.m runtime.m | |
| // Runtime reference, at least until Apple breaks the link | |
| // http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html |