All pastes #2110088 Raw Edit

objc runtime trickery

public text v1 · immutable
#2110088 ·published 2012-02-06 05:09 UTC
rendered paste body
+(Class)signingContextClass {
  static Class theClass = nil;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    Class theMeta;
    Class theSuper = NSClassFromString(@"XCiPhoneOSCodeSignContext");
    theClass = objc_allocateClassPair(theSuper, "MEiPhoneOSCodeSignContext", 0);
    theMeta = class_getSuperclass(theClass);
    Method overriden = class_getClassMethod(theSuper,
                                            @selector(requiresProvisioningProfile));
    class_addMethod(theMeta, @selector(requiresProvisioningProfile),
                    (IMP)*newRequiresProvisioningProfile,
                    method_getTypeEncoding(overriden));
    objc_registerClassPair(theClass);
  });
  return theClass;
}