Reactivecocoa: issue with Interception of a function in RAC5

Created on 22 Jan 2017  路  3Comments  路  Source: ReactiveCocoa/ReactiveCocoa

I was trying to intercept a function named aFunc in my code but I failed.
And then I tried to do the same thing with the function viewWillAppear but this time the function was intercepted successfully.
The code and the log in console is shown below,I have been wondering and could anybody please help me out, thanks~

question

All 3 comments

That is because the function is not marked as dynamic so we cannot intercept (swizzle) the implementation.

To be more specific, Swift methods defined in NSObject subclasses (note: not extensions) by default do not use ObjC message sending. Unless you mark it as dynamic as @ikesyo said, it would use static or vtable dispatch.

Thanks for your reply,it works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonxcheng picture simonxcheng  路  6Comments

BrettThePark picture BrettThePark  路  4Comments

tunidev picture tunidev  路  3Comments

v-silin picture v-silin  路  4Comments

dougmcbride picture dougmcbride  路  3Comments