Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:42:37+00:00 2026-06-03T03:42:37+00:00

I want’ to implement Fix and continue functionality that was in Xcode 3. CONTEXT

  • 0

I want’ to implement “Fix and continue functionality” that was in Xcode 3.

CONTEXT:

The main idea is:
When I need to “Fix something fast”, I’m not re-compiling, project. I’m compiling small Attacker class with ‘updated’ method implementation, loading it into memory and replacing VictimClass’s method which have incorrect implementation in runtime.
I think that this method will work faster that full project recompilation.

When i’m done with fixes i’m just copying source of Attacker class method to Victim class.

PROBLEM

At the moment, I don’t know how correctly call [super ...] in Attacker class.

For example, i have VictimClass

@interface VictimClass : UIView @end
@implementation VictimClass
- (void)drawRect:(CGRect)rect {
  [super drawRect:rect];
}
@end


@interface AttackerClass : NSObject @end
@implementation AttackerClass 
- (void)drawRect:(CGRect)rect {
  [super drawRect:rect];
  [self setupPrettyBackground];
}
@end
....

// EXCHANGE IMPLEMENTATIONS
Method m = class_getInstanceMethod([AttackerClass class], @selector(drawRect:));
const char * types = method_getTypeEncoding(m);
IMP attackerImp = method_getImplementation(m);

class_replaceMethod([VictimClass class], @selector(drawRect:), attackerImp, types);


// Invoking drawRect on Victim
VictimClass * view = /* */;
[view setNeedsDisplay];

At this point , when drawRect: method will be called, this will lead to exception, since drawRect: will be called on NSObject class, but not on UIView class

So, my question is, how correctly call [super drawRect:] in AttackerClass, to have possibility to correctly exchange implementation in runtime?

Main idea is to provide a way to correctly replace any method in Victim class by Attacker’s class method. Generally, you don’t know, superclass of Victim class.

UPDATE: Replacing implementation code added.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:42:38+00:00Added an answer on June 3, 2026 at 3:42 am

    You will have to

    1. get the receivers class (e.g. with object_getClass(rcv))
    2. then get the super class of it (with class_getSuperclass(class))
    3. then get the implementation of it (with class_getMethodImplementation(superclass, sel))
    4. then call the imp.

    done

    Stop at any step if you got nil or NULL.

    Oh, and all this seems silly. But I assume that the question just lacks of context to see the motivation for such a hack.

    [Update]

    An explanation for future readers:

    The super keyword is resolved at compile time. Therefore it does not the intended thing when changing methods at runtime. A method which is intended to be injected in some object (and its class hierarchy) at runtime has to do super calls via runtime as outlined above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
want to ask user to input something but not want to wait forever. There
I need a function that will clean a strings' special characters. I do NOT
want to make an Android app that starts with a main layout and when
Want to develop a query refinement tool just like Google Suggest so that i
want to create a temporary table that has an auto_increment field plus a field
Want to verify that my understanding of how this works. Have a C++ Class
Want make a mind map like the following: Image link is not available anymore.
I have a French site that I want to parse, but am running into
want to ask about void type, so I could know that it works or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.