Permalink
Browse files

Merge pull request #62 from akitchen/master

Wraps fake simulator setup in an autorelease pool
  • Loading branch information...
2 parents 6bce0d7 + ad4fd5b commit be5355df1bbdccd589d3f46929351436f2a992f5 @idoru idoru committed Jan 30, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 Source/iPhone/HeadlessSimulatorWorkaround.m
@@ -3,12 +3,14 @@
void setUpFakeWorkspaceIfRequired() {
#if TARGET_IPHONE_SIMULATOR
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
NSInteger majorVersion = [[[systemVersion componentsSeparatedByString:@"."] objectAtIndex:0] integerValue];
if (majorVersion >= 6 && CFMessagePortCreateRemote(NULL, (CFStringRef)@"PurpleWorkspacePort") == NULL) {
NSLog(@"No workspace port detected, creating one and disabling -[UIWindow _createContext]...");
CFMessagePortCreateLocal(NULL, (CFStringRef)@"PurpleWorkspacePort", NULL, NULL, NULL);
class_replaceMethod([UIWindow class], @selector(_createContext), imp_implementationWithBlock(^{}), "v@:");
}
+ [pool drain];
#endif
}

0 comments on commit be5355d

Please sign in to comment.