Skip to content

Commit

Permalink
Wraps the fake simulator setup in an autorelase pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Kitchen and Philip Kuryloski committed Jan 25, 2013
1 parent 6bce0d7 commit ad4fd5b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/iPhone/HeadlessSimulatorWorkaround.m
Expand Up @@ -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 ad4fd5b

Please sign in to comment.