I want to add code in an existing method during runtime in Objective-C. Is this possible? I checked for reflection in Objective-C, but it has API for adding a class or a method, and modifying a method selector. But I just want to insert code during runtime.
Asked
Active
Viewed 86 times
1
-
Are you asking if you can - while your app is running - type a line of code into a text field, and then have your app compile and execute that code? – DonMag Aug 25 '17 at 18:40
-
Be more specific about what your desired outcome is. – jscs Aug 25 '17 at 20:40
-
I have an existing project. I wanted to add Logs into every method and when Every method is called I want to write that in a log file. I don't want to add a new line of code manually in every method. I am trying to check if there are possibility to add a line of code in every method in the project during run time. – fredrick cyril Aug 26 '17 at 05:22
-
[ObjC track all method calls](https://stackoverflow.com/q/7223555) – jscs Aug 26 '17 at 14:38
1 Answers
1
You should dynamically load classes at runtime. You can't just insert some code during runtime.

Vasilii Muravev
- 3,063
- 17
- 45