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
#import <Foundation/Foundation.h> | |
typedef void (^BlockMockMethod)(NSInvocation *); | |
@interface BlockMock : NSProxy { | |
/* Instance to use as the mock's default target */ | |
id _target; | |
/* Map of NSString selectors to BlockMockMethod blocks */ | |
NSMutableDictionary *_mocks; |
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
#import <Foundation/Foundation.h> | |
@protocol PropertyProtocol | |
@property(readonly) NSString *example; | |
@end | |
int main (int argc, char *argv[]) { | |
id<PropertyProtocol> prop = nil; | |
/* Property access works fine here. */ |
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
#import <Foundation/Foundation.h> | |
/* | |
* File fails to compile with an warning in the ExtendedPropertyClass: | |
* test.m:46: warning: property ‘property’ requires method '-property' to be | |
* defined - use @synthesize, @dynamic or provide a method implementation | |
* | |
* If ExtendedPropertyClass inherits the -method implementation from | |
* PropertyClass, shouldn't it also inherit the -property implementation? | |
*/ |
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
/* | |
* Demonstrates how -copy and -retain are handled for different block types (stack, heap, global). | |
*/ | |
#import <Foundation/Foundation.h> | |
/* print a block -description to stdout */ | |
void PrintBlock (NSString *name, id b) { | |
NSString *str; | |
str = [NSString stringWithFormat: @"%@ (%@):\n\t-retain\t%@\n\t-copy\t%@\n\n", b, name, [[b retain] autorelease], [[b copy] autorelease]]; |
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
/** | |
* An abstract interface that provides purely asynchronous, read-only access to stream-based data. | |
* | |
* TODO: Define end-of-stream handling | |
* | |
* @par Thread Safety | |
* Not Thread-safe. May not be shared across threads. | |
*/ | |
@protocol PLInputStream |
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
/* | |
* If you #import this in every file that uses blocks -- or place | |
* it in a prefix header -- the block runtime symbol references will | |
* be weak linked. Attempting to copy a block will cause a crash | |
* if the block runtime isn't available. | |
* | |
* Use #ifdef __BLOCKS__ to guard the block APIs in your headers so that | |
* they don't cause a parse error with incompatible compilers | |
*/ |
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
# Packet loss rate (percentage, 0.0-1.0) | |
PLR=0.25 | |
# Delay in ms | |
DELAY=300 | |
# Host to filter | |
HOST=example.com | |
ipfw pipe 1 config bw 800Kbit plr "$PLR" delay "$DELAY" |
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
@implementation Logger | |
- (void) writeToLog: (NSString) message { | |
NSLog("%@", message); | |
} | |
@end | |
/* infer the types */ | |
val printer = ^(str) { | |
[self writeToLog: str]; | |
} |
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
landonf@onefish:~> nm /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/PrivateFrameworks/ActorKit.framework/ActorKit| grep '\[' | cut -c 12- | |
+[AKDeferredReply currentReply] | |
+[AKDeferredReply initialize] | |
+[AKDispatchQueue currentRunLoopDispatchQueue] | |
+[AKDispatchQueue migrantDispatchQueue] | |
+[AKDispatchQueue newThreadRunLoopDispatchQueue] | |
+[AKMailbox mailboxWithTarget:protocol:] | |
-[AKActor dealloc] | |
-[AKActor deferredReply] | |
-[AKActor init] |
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
Plausible CrashReporter now provides support for executing your own code in the context of the | |
crash reporter's signal handler, after the crash report has been written to disk. This was a | |
regularly requested feature, and provides a convenient point for performing application finalization. | |
However, there is an important caveat to be aware to when writing code intended for execution inside | |
of a signal handler -- specifically, your code must be async-safe. | |
Program Flow and Signal Handlers | |
When the signal handler is called, the normal flow of the program is interrupted, and your program is | |
an entirely unknown state. Locks may be held, the heap may be corrupt (or in the process of being updated), |