Permalink
Browse files

Wraps the fake simulator setup in an autorelase pool

  • Loading branch information...
1 parent 6bce0d7 commit ad4fd5bc1f2e7b092e870babcaa9c341784955c0 Andrew Kitchen and Philip Kuryloski committed Jan 25, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 Source/iPhone/HeadlessSimulatorWorkaround.m
View
2 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 ad4fd5b

Please sign in to comment.